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]
Related
When I go to http://www.example.com/youtube/detail/abvcde in my browser, I want to internally rewrite the url to http://www.example.com/youtube/detail.php?id=abvcde. I tried to do this with the following .htaccess, but it gives a 404 error.
Currently my .htaccess looks like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
Put the following code in a htaccess file in server root directory:
RewriteEngine On
RewriteRule ^youtube/detail/(.+)$ youtube/detail.php?id=$1 [L]
You can put this code in your /youtube/.htaccess
Options -MultiViews
RewriteEngine On
RewriteBase /youtube/
RewriteRule ^detail/([^/]+)$ detail.php?id=$1 [L]
This url
example.com/ad/load.php?id=pay.jpg
would become
example.com/ad/pay.jpg
I tried to do this.. but it doesn't work.
Here is my htaccess (into ad folder)
Options +FollowSymLinks
RewriteEngine On
RewriteBase /ad/
RewriteRule ^(\w+) ./load.php?id=$1
Edit
on this root example.com/ad/ I want to show index.php but it does not show. how to fix it
You regex should allow dot also. Try this in /ad/.htaccess:
DirectoryIndex index.php
Options +FollowSymLinks
RewriteEngine On
RewriteBase /ad/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([\w.-]+)/?$ load.php?id=$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]
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]