I need to edit my .htaccess
to do something like this: from URL example.com/tag/iphone/iphone-manual
to URL: example.com/iphone/iphone-manual
I just want to remove the tag from its permalink. I don't know whether this could be achieve only by changing htaccess
or it had to edit using PHP too.
Here is my current htaccess
:
RewriteEngine On
RewriteRule ^tag/.* /tag.php [QSA]
RewriteRule ^([^/]+)/$ a-search.php?q=$1
I assume you want to replace the previous "tag rule" inside your .htaccess file? Because it conflicts with what you ask in this question. I'd say all you need to do is this:
RewriteEngine On
RewriteRule ^tag/(.*)$ $1 [QSA,L]
RewriteRule ^([^/]+)/$ a-search.php?q=$1 [L]
If instead you want to add a specific rule , so an exception, then this probably is what you are looking for:
RewriteEngine On
RewriteRule ^tag/iphone/(.*)$ iphone/$1 [QSA,L]
RewriteRule ^tag/.* /tag.php [QSA,L]
RewriteRule ^([^/]+)/$ a-search.php?q=$1 [L]
A general remark: .htaccess
style files are notoriously error prone, they make things complex, are hard to debug and really do slow down the server. They they should only be used in two situations:
In all other cases it makes much more sense to use the real host configuration instead of .htaccess
style files.
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.