I would like this:
http://www.website.com/test/view
to actually call this:
http://www.website.com/index.php/test/view
I tried an .htaccess file that looks like this but it doesn't seem to work:
RewriteEngine on
RewriteCond $1 !^index\.php
RewriteRule ^(.*)$ /index.php/$1 [L]
What am I missing?
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ index.php%{REQUEST_URI} [L]
Did you set "RewriteEngine On" At The first line??
I used this once and it worked fine for me:
RewriteEngine On
RewriteRule ^([a-z\-]+)$ /index.php?page=$1 [L]
Related
I wrote this code into my .htaccess file, but it seems not to work.
RewriteEngine on
Options +FollowSymLinks
RewriteRule ^([^/]*)\.html$ /category/test.php?name=$1 [L]
When writing http://example.com/z.html it automatically redirects me to 404 file.
Do you have any suggestions?
Make sure you have mod_rewrite enabled and try your rules this way.
Options -MultiViews +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.html$ /category/test.php?name=$1 [L]
I have a website in which I want to enter
http://mysite.com/myfolder
but go to (load index.php from)
http://mysite.com/dir/myfolder
So which kind of RewriteRule should I use?
The following rule didn't work and it caused an "500: Internal Server Error" in all pages.
RewriteRule ^$ dir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ dir/$1
Thanks !
The following should work as long as no path includes the "dir" string:
RewriteEngine On
RewriteCond %{HTTP_HOST} !dir
RewriteRule ^(.*)$ http://mysite.com/dir/$1 [R=301,L]
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule (?!^dir/)^(.*)$ /dir/$1 [L,NC]
I have my .htaccess file written as such for my main program in the top directory but also want to exclude a sub-folder where I want to run another program.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond {REQUEST_URI} !=/ecart
RewriteRule ^files/ - [L]
RewriteRule ^(.*)/$ index.php?layers=$1 [L]
</IfModule>
I am trying the RewriteCond but it's not working.
It should go to the ecart/index.php file but still I am being brought to the front domain when I put my address in as www.mydomain.com/ecart
Your code has syntax error with logical errors. {REQUEST_URI} has missing % sign and RewriteCond is applicable to next RewriteRule only. Replace your code with this:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/ecart(/.*|)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?)/?$ /index.php?layers=$1 [L,QSA]
I have the following URL
www.site.com/index.php?key=blah
I want to make it like the following using .htaccess
www.site.com/blah
How can i achieve this using .htaccess?
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+?)/?$ /index.php?key=$1 [L,QSA]
it is what i'm using on my website, it works on local too.
Options -Indexes
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?key=$1 [L]
</IfModule>
how can I do this?
main link:
http://www.domain.com/?link=whatever/something/everythting
convert to:
http://www.domain.com/whatever/something/everythting
I tried with this:
RewriteEngine On
RewriteRule ^([^/]*)$ index.php?link=$1 [L]
But not working.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# If the request is not for a valid link
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ /?link=$1 [L,QSA]
This should work for you:
RewriteEngine On
RewriteRule ^(.+)$ index.php?link=$1 [L]
Edit:
As #anubhava posted in his answer, you should check whether the requested file or directory exists or not in a RewriteCond.
This should work:
RewriteRule ^([^.]+)$ index.php?link=$1 [L]