1

What is the correct syntax to use in an Apache 2.4.7 .htaccess file to get

http://www.example.com/go/stuff

to rewrite to:

http://www.example.com/index.php?tab=go&page=stuff?

What syntax do I use in the RewriteCond and RewriteRule directives?

Warwick
  • 925
  • 1
  • 10
  • 22
  • 1
    Possible duplicate of [How to do URL re-writing in PHP?](http://stackoverflow.com/questions/1039725/how-to-do-url-re-writing-in-php) – Abhishek Gurjar Aug 22 '16 at 10:12
  • Sorry, that did not work. I just get 500 or 404 errors when I try those, including the advice in the link. – Warwick Aug 22 '16 at 10:20
  • you are passing those variables `tab=go&page=stuff` to index.php i assume. – Abhishek Gurjar Aug 22 '16 at 10:31
  • 1
    @Warwick: Can you show your attempted rules in question and also tell what URL is causing 500? – anubhava Aug 22 '16 at 10:35
  • @Abhishekgurjar, sorry, yes, I am passing to index.php – have edited my original post. – Warwick Aug 22 '16 at 10:48
  • @anubhava, I have attempted so many different rules, I don't know where to start! I have just been copying and pasting from the web. I have no knowledge of rewrite syntax at all! – Warwick Aug 22 '16 at 10:48

1 Answers1

1

You can try this rule in site root .htaccess:

RewriteEngine On

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([\w-]+)/([\w-]+)/?$ index.php?tab=$1&page=$2 [L,QSA]
anubhava
  • 761,203
  • 64
  • 569
  • 643