Posts

Showing posts with the label url-rewriting

htaccess redirect and rewrite rules conflicting

Image
Clash Royale CLAN TAG #URR8PPP htaccess redirect and rewrite rules conflicting I want to rewrite all requests to index.php?r= So that /sth becomes /index.php?r=sth I have applied this rule that works: RewriteCond %{REQUEST_URI} !^/index.php$ RewriteCond %{REQUEST_URI} !^.*.(jpg|css|js|gif|png|pdf|php)$ [NC] RewriteRule ^(.+)$ index.php?r=$1 [L] However I want to also have redirects such as Redirect 301 /sth /sth-new What happens is that it works but the url becomes: /sth-new?r=sth Do you have any solutions - suggestions about why this is happening? How can I implement a global rule and also have simple redirects? 1 Answer 1 You can do it like this: RewriteRule ^sth/?$ /sth-new? [L,R=301] RewriteCond %{REQUEST_URI} !^/index.php$ RewriteCond %{REQUEST_URI} !.(jpg|css|js|gif|png|pdf|php)$ [NC] RewriteRule ^(.+)$ index.php?r=$1 [L] You should keep external redirect rules before your internal rewrite rul...

http://localhost/myapp/assets/i18n/en.json not found when angular 6 code deployed on windows 7 IIS server

Image
Clash Royale CLAN TAG #URR8PPP http://localhost/myapp/assets/i18n/en.json not found when angular 6 code deployed on windows 7 IIS server I am trying deploying my application to IIS server on windows 7 PC. The web address is http://localhost/myapp <configuration> <system.webServer> <rewrite> <rules> <rule name="Angular Routes" 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="/MyApp/" /> </rule> </rules> </rewrite> </system.webServer> </configuration> My application runs very good using ...