Creating an SEO friendly URL with Htaccess File

一世执手 提交于 2019-12-20 05:46:31

问题


I am trying to setup an SEO friendly redirect, but need to be using my .htaccess in a specific way. Here is what my URLs look like right now:

http://www.mywebsite.com/report/index.php?id=38678a80dfea5924

I need to change the URLs so that they look like this:

http://www.mywebsite.com/report/38678a80dfea5924

I've read several tutorials about creating SEO friendly URLs, but most of them are referring to making changes to the .htaccess at the root of the domain. Is there any way to do this but only edit the .htaccess file that's in my reports folder?


回答1:


If you've changed all of your links so that they look like this:

http://www.mywebsite.com/report/38678a80dfea5924

Then in the htaccess file inside the "report" folder, you just need:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ index.php?id=$1 [L,QSA]


来源:https://stackoverflow.com/questions/28402242/creating-an-seo-friendly-url-with-htaccess-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!