I'm trying to make www.site.com/web/name to be understood as www.site.com/web?system=name (without the change in URL)
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ $1?system=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ $1?system=$2
.htacceess is located in /web.
This doesn't do anything! Where is my mistake?
You may use these rules in web/.htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L,NE]
RewriteRule ^([\w-]+)/?$ ?system=$1 [L,QSA]
Related
I am having problems with my .htaccess file.
It looks like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^website\.de [NC]
RewriteRule ^(.*)$ http://www.website.de/folder/$1 [L,R=301]
RewriteRule ^traffic/?$ traffic.php [NC,L]
RewriteRule ^what-if/?$ whatif.php [NC,L]
If I call www.website.de/folder/traffic I get www.website.de/folder/traffic/.
But if I call www.website.de/folder/what-if the trailing / is missing.
How can I add it everywhere?
You have to specify a RewriteBase since your htaccess is in a subfolder.
Also, you have to disable MultiViews option to avoid the problem you have.
Options -MultiViews
RewriteEngine On
RewriteBase /folder/
RewriteCond %{HTTP_HOST} ^website\.de$ [NC]
RewriteRule ^(.*)$ http://www.website.de/folder/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.+)$ $1/ [R=301,L]
RewriteRule ^traffic/$ traffic.php [NC,L]
RewriteRule ^what-if/$ whatif.php [NC,L]
I would like to hide the index.php page and just show the domain.
Is this possible with .htaccess?
RewriteRule ^index\.php/?$ / [L,R=301,NC]
Also tried:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.php HTTP/
RewriteRule ^index.php$ http://example.com/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
index.php still shows
Try, It works for me! Make sure your have AllowOverride All set in httpd.conf
RewriteEngine On
RewriteCond %{REQUEST_URI} index\.php
RewriteRule ^(.*)index\.php$ /$1/ [R=301,L]
There is a regex issue in your rules, I have modified your rules and it works for me:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} index\.php
RewriteRule ^index\.php$ http://example\.com/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index\.php [L]
RewriteRule ^(.*)index\.(html|php)$ http://%{HTTP_HOST}/$1 [R=301,L]
You can rewrite '/index.php' through .htaccess like this:
# Remove /index.php from all urls
RewriteRule ^(.+)/index\.php$ /$1 [R=302,L]
What is wrong with this line
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?query=$1 [L]
I'm try rewrite links from
http://mysite.com/index.php?query=2012
to
http://mysite.com/2012
But i have 500 Internal Server Error
Also here is the content from my htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^software$ index.php?type=app
RewriteRule ^movies$ index.php?type=movie
RewriteRule ^games$ index.php?type=game
RewriteRule ^music$ index.php?type=music
RewriteRule ^other$ index.php?type=other
RewriteRule ^tv$ index.php?type=tv-show
RewriteRule ^ebooks$ index.php?type=ebooks
RewriteRule ^(.*)-(\d+)\.html$ download.php?id=$2 [L,NC]
RewriteRule ^site/([^/]*)$ /index.php?site=$1 [L]
RewriteRule ^([^/]*)$ /index.php?query=$1 [L]
Replace this rule:
RewriteRule ^([^/]*)$ /index.php?query=$1 [L]
with this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/]*)/?$ index.php?query=$1 [L,QSA]
how to add / at the end using following code after removing html extension:
Options +FollowSymLinks -MultiViews
DirectorySlash off
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME}/ -d
RewriteCond %{SCRIPT_FILENAME}.html !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)\.html$ /$1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME}.html -f
RewriteRule [^/]$ %{REQUEST_URI}.html [QSA,L]
You will need to make some changes.
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
#Code to add forward slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(?:\.\w+|/)$
RewriteRule (.*) $1/ [R,L]
#To check whether a .html appended string is a file existing on the system
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule (.*)/ $1.html [L]
#### NOT REQUIRED
#RewriteCond %{SCRIPT_FILENAME}/ -d
#RewriteCond %{SCRIPT_FILENAME}.html !-f
#RewriteRule [^/]$ %{REQUEST_URI}/ [R,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)\.html$ /$1 [R,L]
Also these rules will not work as desired:
RewriteCond %{SCRIPT_FILENAME}.html -f
RewriteRule [^/]+/$ %{REQUEST_URI}.html [QSA,L]
cos, %{REQUEST_URI} will always have / at the end. If a URI like domain.com/about is requested for,
It will be rewritten to:
domain.com/about/
and finally to
domain.com/about/.html
Trying to add trailing slash to every link. i.e. http://mysite.com/products should make 301 redirect to http://mysite.com/products/ etc. But how? Here is htaccess:
RewriteEngine on
DirectoryIndex index.php
Options -Indexes
RewriteBase /
RewriteCond %{REQUEST_URI} \.css$
RewriteCond %{QUERY_STRING} ^pack$
RewriteRule ^(.*)$ /modules/system/css_compactor.php?filename=$1 [L]
RewriteCond %{REQUEST_URI} \.js$
RewriteCond %{QUERY_STRING} ^pack$
RewriteRule ^(.*)$ /modules/system/js_compactor.php?filename=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php
RewriteRule /admin/(.*)$ /admin/index.php
Need help!
Here's what I'm using
RewriteEngine on
RewriteBase /
### CHECK FOR TRAILING SLASH - Will ignore files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://example.com/$1/ [L,R=301]
Basically, this makes sure that it doesn't add a trailing to file and only folders or paths.
EDIT
To make it domain independent
RewriteRule ^(.*)$ $1/ [L,R=301]