mod_rewrite Assitance
I need some help about mod_rewrite,
this is my wordpress address:
http://localhost/my_v2010/restaurants?m=display_Add
base_url: http://localhost/my_v2010/
post_name:restaurant
query string:?m=display_Add
I would like to use rewrite mode, let user just type
http://localhost/my_v2010/restaurants/display_Add
any clue how to write in .htaccess?
I tried
RewriteEngine On
RewriteBase /my_v2010/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /my_v2010/index.php [L]
RewriteRule ^restaurants/([^/]+)/?$ restaurants?m=$1 [L]
but no luck, it didn't show what http://localhost/my_v2010/restaurants?m=display_Add had shown. So I need your 开发者_高级运维guys help. Thanks a lot!
Force the custom URL redirection back to the browser so WordPress can understand it:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /my_v2010/
RewriteRule ^restaurants/([^/]+)/?$ restaurants?m=$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /my_v2010/index.php [L]
</IfModule>
# END WordPress
That will rewrite the request to the expected format and then come through again, piping it through the index.php page for WordPress.
try reordering you rules. the [L] tag means it is the last rule that gets run.
I change to
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /my_v2010/
RewriteRule ^restaurants/([^/]+)/?$ restaurants?m=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /my_v2010/index.php [L]
</IfModule>
# END WordPress
it become 404 not found.
so what I think is http://localhost/my_v2010/restaurants/display_Add didn't end up like http://localhost/my_v2010/restaurants?m=display_Add
I still able to get http://localhost/my_v2010/restaurants?m=display_Add run, but not http://localhost/my_v2010/restaurants/display_Add
精彩评论