Last active
August 16, 2024 06:02
-
-
Save bramus/5332525 to your computer and use it in GitHub Desktop.
URL Rewriting for Apache (requires mod_rewrite) and IIS (requires IIS url rewrite module)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . index.php [L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<system.webServer> | |
<rewrite> | |
<rules> | |
<rule name="Main Rule" stopProcessing="true"> | |
<match url=".*" /> | |
<conditions logicalGrouping="MatchAll"> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> | |
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> | |
</conditions> | |
<action type="Rewrite" url="index.php" /> | |
</rule> | |
</rules> | |
</rewrite> | |
</system.webServer> | |
</configuration> |
try_files $uri $uri/ /index.php?$args;
Works man.
NGINX
location / { try_files $uri /index.php; }
That will lost $_GET contents.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To follow up on @RedShift1's answer from above, if you'd like to make this work in a virtual host configuration in apache you don't need to put the
.htaccess
file in the project's root folder.This is my
sites-available/<my-domain>.conf
: