Forum Moderators: phranque
Options +FollowSymlinks
RewriteEngine on
# Sends requests to domain.com/ to domain.com/index.html
RewriteRule ^$ /index.html [N]
# If the request comes from /myform.php, then remap the value of the C parameter to the domain root
# e.g.: domain.com/myform.php?c=VAR to domain.com/VAR
RewriteCond %{REQUEST_URI} /myform.php$
RewriteCond %{QUERY_STRING} ^c=(.+)
RewriteRule ^myform\.php$ /%1? [R=301,L]
# Replace + and ' with hyphens
# e.g.: domain.com/FOO+BAR to domain.com/FOO-BAR
RewriteRule ^([^+]*)\+(.*) $1-$2 [N]
RewriteRule ^([^+]*)\'(.*) $1-$2 [N]
# Replace spaces with hyphens
# e.g.: domain.com/FOO BAR to domain.com/FOO-BAR
RewriteRule ^([^\ ]*)\ (.*)$ $1-$2 [E=rspace:yes,N]
# Redirect to update URL in search engine listings and browsers
# e.g.: My URL becomes domain.com/A-VAR
RewriteCond %{ENV:rspace} yes
RewriteRule (.*) /$1 [R=301,L]
# Send the actual request (unless the name includes a . or a /)
RewriteRule ^([^/.]*)/?$ /myform.php?p=&c=$1
RewriteRule ^([^+]*)\+(.*) $1-$2 [N]
RewriteRule ^([^+]*)\'(.*) $1-$2 [N]
Options +FollowSymlinks
RewriteEngine on
# Sends requests to domain.com/ to domain.com/index.html
RewriteRule ^$ /index.html [N]
# If the request comes from /myform.php, then remap the value of the C parameter to the domain root
# e.g.: domain.com/myform.php?c=VAR to domain.com/VAR
RewriteCond %{REQUEST_URI} /myform.php$
RewriteCond %{QUERY_STRING} ^c=(.+)
RewriteRule ^myform\.php$ /%1? [R=301,L]
# Replace + and ' and <spaces> with hyphens
# e.g.: domain.com/FOO BAR+FOO'BAR to domain.com/FOO-BAR-FOO-BAR
RewriteRule ^([^+]*)\+(.*$) $1-$2 [E=rspace:yes,N]
RewriteRule ^([^+]*)\'(.*)$ $1-$2 [E=rspace:yes,N]
RewriteRule ^([^\ ]*)\ (.*)$ $1-$2 [E=rspace:yes,N]
# Redirect to update URL in search engine listings and browsers
RewriteCond %{ENV:rspace} yes
RewriteRule (.*) /$1 [R=301,L]
# Send the actual request (unless the name includes a . or a /)
# Still not sure why I need the extra p=
RewriteRule ^([^/.]*)/?$ /myform.php?p=&c=$1
# ErrorDocument 404 /404.html
# Declare custom 404 error page
# ErrorDocument 404 /404.html
#
# Map requests for URL domain.com/ to filepath /index.html
DirectoryIndex /index.html
#
Options +FollowSymlinks -MultiViews
RewriteEngine on
#
# Replace one "+", "'" or space with a hyphen and set "character replaced"
# flag, then restart mod_rewrite processing until all have been replaced
# e.g.: domain.com/FOO BAR+FOO'BAR to domain.com/FOO-BAR-FOO-BAR
RewriteRule ^([^+]*)[+'\ ](.*$) $1-$2 [E=rspace:yes,N]
#
# If the character replaced flag is set, redirect to update
# the URL in search engine listings and browsers
RewriteCond %{ENV:rspace} =yes
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# If the request is for URL-path /myform.php, then redirect to root with the C
# parameter as a "filepath" e.g.: domain.com/myform.php?c=VAR to domain.com/VAR
RewriteCond %{QUERY_STRING} ^c=(.+)
RewriteRule ^myform\.php$ http://www.example.com/%1? [R=301,L]
#
# Internally rewrite the request to /myform.php (unless the name includes a . or a /)
# Still not sure why I need the extra p=
RewriteRule ^([^/.]*)/?$ /myform.php?p=&c=$1
My script redirects you to a 404