简体   繁体   中英

SEO friendly URL not working

I have a URL (Example.com/blog/) and blog is a directory in my website root. blog contains an index.php file that generates a page based on the query string of ?url=[some url] for example let's say example.com/blog/?url='hello-world' is a valid query string where information can be generated. I want that URL to be example.com/blog/hello-world

Currently, I have a global .htaccess file that removes all extensions. Inside my blog directory is another .htaccess file. It has my attempt at making the URL change to the friendly URL:

RewriteEngine on
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(blog)/(.*)$ blog/index.php?url=$2 

Unfortunately, this isn't working. How can I solve this problem so the friendly URL displays?

Try this it like this,

RewriteEngine on
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /blog/?url=$1 [QSA,NC,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM