MR Skan
MR Skan

Reputation: 89

Htaccess rewriting rule for localhost

The project is already running in prod, the developer who added that rule is no longer working with us but it is pretty working in prod, so in order to have the project working locally I tried many options, now I set the SSL in my web server and set virtual host to match exactly the prod so that it can run correctly, in the code the sign form is sent by session but it is blocked for security reason and I am pretty sure that it is related to htaccess and here are the full rules mentioned in htaccess: # -- SITE PAGES ---

RewriteRule ^(.+)\.html$ index.php?_htaccess_url=$1&%{QUERY_STRING} [L]
RewriteRule https://www.sanatariol.com(.+)\.html$ index.php?_htaccess_url=$1&%{QUERY_STRING} [L]

The URL of sign page is: https://www.sanitavia.com/cabchatt/connexion.html

Do I have to add a rule in htacces since I want it to run locally?

Upvotes: 2

Views: 96

Answers (2)

MrWhite
MrWhite

Reputation: 45829

RewriteRule https://www.sanatariol.com(.+)\.html$ index.php?_htaccess_url=$1&%{QUERY_STRING} [L]

The RewriteRule directive matches against the URL-path only (not the absolute URL). So, the above rule will not match.

Try the following instead:

RewriteRule (.+)\.html$ index.php?_htaccess_url=$1 [QSA,L]

You also don't need to manually append the query string, use the QSA (Query String Append) flag instead.

Upvotes: 0

Romelou Striga
Romelou Striga

Reputation: 96

the rule is correct but try to add this just before your rule

    RewriteBase /

# 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

Upvotes: 1

Related Questions