简体   繁体   中英

HTACCESS Clean URL without breaking the Query String

This code below does exactly what I wanted to do, but the problem is that it breaks the query string. Whatever am passing into the URL is not being recognized by PHP $_GET. Is there a way I can use this code and also not break and query string am using on URL.

I' am just a beginner with HTACCESS, I do not have much knowledge about this.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([-\w]+)?/?([-\w]+)?/?([-\w]+)?/?$ index.php?slug1=$1&slug2=$2&slug3=$3&slug4=$4&slug5=$5

The original query string is automatically added to the substitution URL unless you specify a query string in the substitution URL explicitly. In that case, you have to use the [QSA] flag in the rewrite rule to merge the original query string into the substitution query string.

For details, see what the documentation of RewriteRule says about "Modifying the Query String".

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