问题
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