0

Im having a weird issue here; The following .htaccess works but now (after changing to a dedicated server) it just appends the variable at the end of the url at the browser's address bar; For example:

If I call this.. http://www.mydomain.com/sports

It gets rewrote like this.. :( http://www.mydomain.com/index.php?u=sports

I just want it to stay like exactly like it was called :)

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ http://www.mydomain.com/index.php?u=$1 [NC]

Thanks in advanced!

3
  • I tried that, but it return a 400 Bad Request error :/ Commented Mar 23, 2012 at 6:07
  • @Seybsen just the .htaccess, why? Commented Mar 23, 2012 at 6:07
  • Also, its adding a this to the end when called for www.mydomain.com: mydomain.com/index.php?u=index.html.var and that "index.html.var" part idk where it comes from :/ Commented Mar 23, 2012 at 6:11

1 Answer 1

1

The last rule should look like this:

RewriteRule ^([^?]*) index.php?u=$1 [L,QSA]

[QSA] - When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.

[L] - The [L] flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed. This corresponds to the last command in Perl, or the break command in C. Use this flag to indicate that the current rule should be applied immediately without considering further rules.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.