Forum Moderators: phranque
RedirectMatch 301 ^/folder http://www.example.com/page.html
redirect 301 /folder http://www.example.com/page.html
redirect 301 /page2.html http://www.example.com/page2.shtml
redirect 301 /page3.html http://www.example.com/page3.shtml
redirect 301 /page4.html http://www.example.com/page4.shtml
RewriteRule ^page([234])\.html http://www.example.com/page$1.shtml [R=301,L]
Options -Indexes
ExpiresActive on
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
# phprint file can't be cached
<Files phprint.php>
ExpiresDefault A0
</Files>
# Set up rewriting
Options +FollowSymLinks
RewriteEngine On
# specific redirects for old links and 404s
RewriteRule ^page\.s?html$ http://www.example.com/new-page.php [R=301,L]
# redirect all .html and .shtml requests to .php
RewriteRule ^(([^/]+/)*[^/.]+)\.s?html?$ http://www.example.com/$1.php [R=301,L]
# set all URLs to www versions
RewriteCond %{HTTP_HOST} ^[0-9]+(\.[0-9]+){3} [OR]
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
# add utf-8 to all text file types
<FilesMatch "\.(htm|html|shtml|css|js|php)$">
AddDefaultCharset UTF-8
</FilesMatch>
# custom 404 page
ErrorDocument 404 /404.php
RewriteRule ^index\.php$ http://www.esl-lounge.com/ [R=301,L]
I'm guessing that's because when a / link is clicked, the server serves up index.html which is then turned into index.php. Does that sound right?
It's unusual for a folder to redirect elsewhere whilst pages inside the folder do not.
By default, the DirectoryIndex is selected and returned transparently to the client. DirectoryIndexRedirect causes an external redirect to instead be issued.
...
A request for http://example.com/docs/ would return a temporary redirect to http://example.com/docs/index.html if it exists.
I'm guessing that's because when a / link is clicked, the server serves up index.html which is then turned into index.php.
DirectoryIndex index.php Obviously when there are two index files, the full filepath is shown with the /index.php appended, to show you which one is being served up. Doh!
DirectoryIndex list. A rewrite might then force a name change and a redirect expose that name. That would be a coding error. The index filename shouldn't be seen. I added a rewrite rule which caused a loop:
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(php|s?html?)
RewriteRule ^(([^/]+/)*)index\.(php|s?html?)$ http://www.example.com/$1? [R=301,L] RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteCond %{REQUEST_URI} ^php-ads-new/[a-z-]\.php [NC]
RewriteRule .* - [F,L]
GET /somefile HTTP/1.1 RewriteCond %{REQUEST_URI} ^php-ads-new/[a-z-]\.php [NC]
RewriteRule .* - [F,L] RewriteRule ^php-ads-new/[a-z-]\.php - [F,NC] why would you ever use a RewriteCond for a URL match
the RewriteCond condition pattern "is a perl compatible regular expression with some additions":
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
... including using the '!' as a negation character to specify a non-matching pattern...
RewriteRule !^(robots\.txt)$ http://www.example.com/$1 [R=301,L] RewriteCond %{REQUEST_URI} !^/robots\.txt
RewriteRule (.*) http://www.example.com/$1 [R=301,L]