skip to Main Content

The rewriterule that I am using on localhost works the way I want it to work, but when I upload it to the server, it just doesn’t anymore.

RewriteRule ^(.*)$ index.php?url=$1 [QSA]

Locally it gives the desired url, localhost/links/ … But as soon as it’s on the server, I get this: www.domain.com/index.php?url=links/

I don’t understand why that is… and is there a way to fix it?

2

Answers


  1. Chosen as BEST ANSWER

    I found the answer, thanks AI...

    Simply put, I just needed to add:

    RewriteBase /
    

    The only downside is that on localhost it redirects me to http://localhost/, but it works on the server.


  2. Check the following:

    1. Make sure .htaccess overrides are allowed in your server’s configuration.
    2. Enable the mod_rewrite module in Apache using a2enmod rewrite.
    3. Use absolute paths in your RewriteRule to ensure consistency between server and
      localhost like below:
    RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
    
    
    1. Confirm that your application’s base URL is configured correctly in code & clear
      the browser cache
    2. Look for mod_rewrite-related messages in the server’s error logs.
    3. If on shared hosting, consult your hosting support if the issue persists.
    4. Your directory structure and .htaccess file’s location should match on server &
      localhost.
    5. Try different flags like [QSA,L,NC] in your RewriteRule if needed.

    Note: If none of these steps resolve the issue, consider seeking assistance from your hosting provider’s support or a server administrator to diagnose and fix the problem.

    #Apache-Age

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search