Simple Apache .htaccess RewriteRule
I basically want each request to
http://localhost/~lucamatteis/datadict/AccessionMainName
to actually call开发者_StackOverflow中文版
http://localhost/~lucamatteis/datadict/index.php/AccessionMainName
Here's my current .htaccess
physically located under ~lucamatteis/datadict/
RewriteEngine on
RewriteBase /~lucamatteis/datadict/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
But unfortunately this doesn't work. I've tried everything. At this point I think the issue is that It's using the tilde, or I'm not sure.
In the phpinfo()
under the loaded modules section mod_rewrite
is loaded. I'm not sure where else to look as I might need to load an extra thing for mod_rewrite to work.
Any ideas?
First of all make sure that you're able to override Apache configuration trough .htaccess file ( AllowOwerride
config directive).
Then try to remove RewriteBase
directive totally. In this case the current directory will be used as base.
Change you ReWriteBase to your physical directory:
/home/lucamatteis/public_html/datadict (or something similar)
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteBase
I think the problem is that you want to do an internal redirection to a file that does not exists:
/home/lucamatteis/public_html/datadict/index.php/AccessionMainName
This will only work if index.php is a directory and AccessionMainName is a file.
I don't think such thing can be done. Most of the times, using query string parameters is all you need:
index.php?AccessionMainName
... and you read it from $_GET['AccessionMainName']
.
精彩评论