1

What I need to do is change the links on my website, for example from

www.mywebsite.com/index.php

www.mywebsite.com/index.php?action=about_us

to

www.myswebsite.com/index.html

www.myswebsite.com/about_us.html

I was told htaccess was used to acheive this and I presume this is achieved with some sort of regular expression.

How can I achieve this result?

4
  • Well as you can see by the title i didnt quite know how to word it and find what i needed... with no thanks to you i had a brainwave and typed in module-rewrite and now finally getting somewhere...
    – Riskeh
    Oct 5, 2010 at 22:02
  • lol dont be mean, it's ok we've all been through it. He's a new user. Dont worry about it. Riskeh, make sure you try doing some extensive research yourself as well when before posting a question. After you have exhausted everything you can think of.
    – Pavan
    Oct 5, 2010 at 22:02
  • dont worry ive posted something for you.
    – Pavan
    Oct 5, 2010 at 22:03
  • thank you very much pavan and will keep that in mind
    – Riskeh
    Oct 5, 2010 at 22:08

3 Answers 3

1

you have

www.mywebsite.com/index.php?action=about_us

and you want

www.myswebsite.com/about_us.html

in your .htaccess file add a line to the end of this file:

redirect /about_us http://www.myswebsite.com/about_us.html

voila

http://affiliate-minder.com/internetmarketing/using-htaccess-file-for-affiliate-link-redirects/

PK

1

Turn on the rewrite engine. The RewriteRule will fetch the page in the second parameter when the first parameter is called. So www.myswebsite.com/about_us.html will load www.mywebsite.com/index.php?action=about_us, but the URL in the address bar will still be www.myswebsite.com/about_us.html. The [NC] at the end just makes it case insensitive.

RewriteEngine On
RewriteRule ^/about_us\.html$ index.php?action=about_us [NC]

More info: http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html

0
CheckSpelling on
Options -Indexes
Options +FollowSymlinks

DirectoryIndex index.php

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$\.html /index.php?action=$1 [L,QSA]

and from there, you could use index.php to either navigate, or just display the content

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.