0

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
Patrick Mevzek
  • 10,995
  • 16
  • 38
  • 54
pingu
  • 31
  • 1
  • 3

1 Answers1

0

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:

  1. if you do not have access to the real host configuration (otherwise palce the rules in there!)
  2. if you require dynamic changes to the rule set by some web application (though think twice about the security implications)

In all other cases it makes much more sense to use the real host configuration instead of .htaccess style files.

arkascha
  • 41,620
  • 7
  • 58
  • 90
  • i have applied this code to my website : RewriteRule ^tag/(.*)$ $1 [QSA,L], but it seem to redirect me to 404 pages, when i open my site at : mysite.com/iphone/iphone-manual-download instead of : mysite.com/tag/iphone/iphone-manual-download, i want to share my website privately to you, how i can contact you, thanks.. – pingu May 25 '14 at 13:04
  • Sorry, only came back from a meeting now. Sure I can give you a hand if you like. Ah, darn, I just see that do not have enough points for chat. Stupid rule, actually. Give it a try here: "so attt christian-reiner.info" :-) – arkascha May 25 '14 at 20:26