开发者

Apache 2 - Mod rewrite is installed and active but I can't get it to work... what am I doing wrong?

Mod Rewrite is activated an enabled as far as I can tell (I followed the tutorial to install it and activate it using a2enmod rewrite).

I'm trying to set up some pretty URLS using PHP - prettymuch I want:

mysite.com/sites/mysite/blog/article-title-here/

instead of mysite.com/sites/mysite/blog/index.php?article=article-title-here

I'm following Nettuts tutorial here to the letter. (the Using PHP portion anyway)

Options +FollowSymLinks  
RewriteEngine On  

RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  

RewriteRule ^.*$ ./index.php  

I've even looked at some of the Questions with similar titles and tried following the solutions for them开发者_如何学C as well, but I just get the standard 404 still.

I'm pretty new to the whole server admin thing and am learning as much as I can through a low cost naked VPS. It's challenging and fun, but this has me pulling my hair out.


You should use the Apache section rather than PHP if possible.

Mod rewrite is one of those bits of code that is much more complex than would be seen at face value to it is worth looking at a few tutorials/examples/references when coding it to make sure that you haven't missed something important under your usage.

This code is based on minimum requirements based on your question, these happen to be my minimum requirements for the site I have implemented it for and if there are other variables you may need to adjust it to suit. E.g. other variables in the URL string will need to be added and changing the path.

Options +FollowSymLinks  
RewriteEngine On  
RewriteRule ^sites/mysite/blog/([^/]*)$ ./index.php?article=$1

Here is another reference that may help you.

I hope this helps :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜