What I need to do is change the links on my website, for example from
www.mywebsite.com/index.php
www.m开发者_StackOverflow社区ywebsite.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?
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
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
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
精彩评论