mod_rewrite to index.html breaks relative paths for deep URLs

I got it to work and this is how: When you give the following as the src: <script src=”https://stackoverflow.com/questions/10865480/js/app/config.js”></script> you’re right in that Apache correctly reroutes to index.html (or whatever fallback URL you have) and then tries to access resources relatively according to nested path in the URL. To correct this, you need to have … Read more

How to create clean url using .htaccess

Replace your code with this: ErrorDocument 404 /404.php AddDefaultCharset UTF-8 Header unset ETag FileETag None Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+movie\.php\?name=([^\s&]+) [NC] RewriteRule ^ movie/%1? [R=301,L] RewriteRule ^movie/([^/]+)/?$ movie.php?name=$1 [L,QSA]

htaccess code to remove extension AND add+force trailing slash?

Try this: RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php RewriteRule (.*)\.php$ /$1/ [L,R=301] RewriteRule (.*)/$ $1.php [L] The first rule redirects requests of /foo/bar.php externally to /foo/bar/. And the second rule rewrites requests of /foo/bar/ internally to /foo/bar.php. And to force the trailing slash, try this rule: RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule .*[^/]$ $0/ [L,R=301]

htaccess force https and redirect www to non-www, but no other subdomains

I found most of the suggestions were not catching when you had something that was https://www.example.com and redirecting to https://example.com. The following worked for all permutations: RewriteEngine On # match any URL with www and rewrite it to https without the www RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC] RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301] # match urls that are … Read more

mod_rewrite: what does this RewriteRule do?

The RewriteCond directive just describes an additional condition for a RewriteRule directive. So RewriteCond must always be associated with a RewriteRule. In your case the three RewriteCond probably belong to the first RewriteRule like this: RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ – [NC,L] Now this rule is applied … Read more