1

So I've used an online .htaccess editor and it's not working for some reason on my test server, here's the content of my .htaccess file.

RewriteEngine On
RewriteRule ^Page/([^/]*)/$ /?Page=$1 [L]

I have also enabled the LoadModule rewrite_module modules/mod_rewrite.so on my WAMP server. Any help is much appreciated.

[Fri Aug 09 12:46:10.130887 2013] [core:alert] [pid 1424:tid 1532] [client 127.0.0.1:50725] C:/wamp/www/Website/.htaccess: RewriteRule: bad flag delimiters

EDIT: tried doing one on my own still having the same issue

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^Page/([a-zA-Z]+)/([0-9]+)/$ index.php?Page=$1
5
  • mod_rewrite is doing something - it appears to be enabled and is giving you this error. However, it looks OK to me. Check for unwanted whitespace, especially at EOL, and for any non-visible characters.
    – MrWhite
    Commented Aug 9, 2013 at 16:51
  • When I checked the doesn't seem to be any non-visible characters, maybe if I were to describe what I want the rewrite to do that may clear up the problem. What I want it to is to change where is says something like ?Page=Home to /Page/Home/
    – Callum.K
    Commented Aug 9, 2013 at 17:30
  • Hhmmm, your .htaccess would seem to be doing the complete opposite at the moment? The code you currently have would normally be required for "user friendly/pretty" URLs and internally rewrites /Page/Home/ to /?Page=Home. However, the 'change' in your comment would be an external redirection to the canonical URL. You could have both?
    – MrWhite
    Commented Aug 9, 2013 at 19:31
  • I'm not quite sure what you are saying, I'm trying to change a $_GET variable to something like /Page/Home/. Which part would I need to do to change this, or would I have to change the whole thing?
    – Callum.K
    Commented Aug 9, 2013 at 19:46
  • Please state which "online htaccess editor" you "used", preferably by creating a link to it. And since the commentary has revealed essential info missing from the question (i.e. what you're trying to do), please edit the question to include that info.
    – Fred Gandt
    Commented Jun 5, 2017 at 21:35

1 Answer 1

0

It seems from comments that you are wanting to redirect (I assume) ?Page=Home to /Page/Home/ rather than rewrite the other way round, as you are trying to do in your question?

In which case you would need to do something like:

RewriteCond %{QUERY_STRING} ^Page=(.*)$
RewriteRule .* /Page/%1/? [R=301,L]

NB: The ? at the end of the RewriteRule substitution removes the original querystring.

4
  • I'm not trying to redirect the user I'm trying to change the look of the $_GET variable so it looks like /Page/Home and not ?Page=Home. Thanks anyways.
    – Callum.K
    Commented Aug 10, 2013 at 0:07
  • Sorry, I'm not sure that I follow. It looks like you are trying to implement "friendly URLs" ie. /Page/Home rather than ?Page=Home? However, in this case you shouldn't be changing the (look of the) $_GET variable. The $_GET variable would remain the same, but the URL in the address bar is changed to "look friendly". The requested (friendly) URL is internally rewritten (as you are trying to do in the question) back to a querystring to give you your $_GET variable. OR maybe you're doing something completely different? :)
    – MrWhite
    Commented Aug 10, 2013 at 1:36
  • That is indeed what I am trying to get but the code you sent me adds /Page/Home however the $_GET is not changed and still remains there so the url now looks like /Page/Home?Page=Home.
    – Callum.K
    Commented Aug 10, 2013 at 4:42
  • Sorry, there should have been a ? at the end of the RewriteRule substitution string to remove the original querystring - I've updated my answer. Is this what you require? To be honest, the code you have in your question is what is required to implement user friendly URLs. This bit here (to redirect from unfriendly to friendly) is only really required if you have an existing "unfriendly" URL structure that you are changing (although it is a good thing to do anyway).
    – MrWhite
    Commented Aug 11, 2013 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.