2

My mates and I are putting the finishing touches on our website hosted with ipage but we are just having one small issue with our .htaccess.

We want to make our urls SEO friendly (and neat) and the rewriterule is not working, we keep getting 404 errors. I just want to verify the syntax is correct. I have questioned it with ipage and they said mod_rewrite is installed and allowoverride all is set but couldn't help with the regular expression.

The url is:

http:// www.example.com/article.php?title=Some-Article

and we want to make it:

http:// www.example.com/Some-Article

the entire htaccess file:

# Protect db_connect
<files db_connect.php>
order allow,deny
deny from all
</files>

# Protect .htaccess
<files .htaccess>
order allow,deny
deny from all
</files>

Options +FollowSymLinks 
Options +Indexes
RewriteEngine On

# Remove .php but still allow addressing .php
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteRule ^([^/]*)/$ /article.php?title=$1 [L]

Any help would be greatly appreciated as I have searched for hours and also tested the syntax generated from http://www.generateit.net/mod-rewrite/ with no luck.

Regards,

Adam

4

1 回答 1

0

多谢你们,

我和我的伙伴们最终对它进行了排序,我们在后端更改了一些东西,以使 url 更改为:

http://www.example.com/article.php?title=Some-Article

至:

http://www.example.com/article.php?article=Some-Article

然后对 .htaccess 文件进行以下调整,我们让它工作:

RewriteEngine On
RewriteRule page/([^/]*)/$ /index.php?p=$1 [L]
RewriteRule ^product/([^/]*)$ /article.php?article=$1 [L]
RewriteRule ^([^/]*)/$ /index.php?sort=$1 [L]
RewriteRule ^([^/]*)/page/([^/]*)$ /?sort=$1&p=$2 [L]

所以我们现在形成了以下网址:

http://www.example.com/page/2

http://www.example.com/product/Some-Product/

http://www.example.com/

http://www.example.com/category/page/2

调试确实有帮助,感谢它,我在 php.ini 中调高了错误报告级别并将其输出到我可以通过 FTP 访问的文件。

于 2013-06-03T22:31:03.960 回答