I have written below code in htaccess
RewriteRule ^([a-zA-Z_-]+).php$ http://www.domain.com/myfile.php?page=inc-$1.php [NC]
I don't want to rewrite index.php file. index.php file should open as it opens. and i also not using any sepecrator "dir/" in htaccess. Mainly how will i check for specific strings to allow ?
Thanks
You can add a rewrite condition for index.php before your RewriteRule
RewriteCond %{REQUEST_URI} !^index\.php$
So it will not redirect index.php
Related
Can you please show me how to create rewrite rule in htaccess to convert from default.asp to index.php with the same directory?
Here is what I have so far
RewriteRule ^(.*)\.asp$ ^(.*)\index.php$ [R,L,NC]
But it is not working. I like to be able to convert from defaut.asp to index.php regardless of the URL structure.
For example, if https://myownsite.com/about/that/default.asp then it will become https://myownsite.com/about/that/index.php
Thank you
You can use this :
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/(.*?)default\.asp$
RewriteRule ^ /%1index.php [R=301,L]
How to create redirection rule in .htaccess for:-
earlier we have 400+ paths like.
/blog/some-path1
/blog/some-path2
but now we have paths like.
/some-path1
/some-path2
How to create single line redirection rule for above redirection without write multiple redirections.
tried below rule but not working
RewriteEngine on
RewriteBase /
RewriteRule ^blog/(.*)$ /$1 [L,NC,R]
Try with below rule, I am assuming you know the paths are defined correctly, clear cache beforehand.
RewriteEngine On
RewriteCond %{REQUEST_URI} ^blog/(.+)
RewriteRule ^ /%1 [R=301,L]
I'm running a Magento site and needed to upload a google site ownership confirmation file to the root. When I did this, html file was not accessible via url when typed as follows www.website.com/google0564e497cc4446t6.html instead I got a 404 page. Other file formats work just fine. I concluded that there must be a .htaccess redirect.
This is the .htaccess content:
## enable rewrites
Options +FollowSymLinks
RewriteEngine on
## RewriteRule ^(.)ItemDesc.asp?IC=(.)$ $1$2 [L]
## RewriteRule ^supply-items/$ ItemDesc.asp?IC= [NC,L]
RewriteRule ^([^/]*)\.html$ /ItemDesc.asp?IC=$1 [L]
##RewriteRule ^ItemDesc.asp?IC=$ supply-items/ [L,R=301]
RewriteRule test_rewrite\.html http://www.website.com/rewrite_successful.html [R=301,L]
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
As it turns out the previous website redirects are very important for maintaining of SEO, so I cannot just remove them. However, is there a way to make an exception to specific .html files such as www.website.com/google0564e497cc4446t6.html using the .htaccess file?
Thank you!
You can modify the first part of your rule and add a condition to skip the google file.
RewriteCond %{REQUEST_URI} !^/google(.*)\.html$
RewriteRule ^([^/]*)\.html$ /ItemDesc.asp?IC=$1 [L]
I am trying to run a mod_rewrite rule to load the contents of index.php regardless of the entered URL.
Then in the index.php file I will deal with either returning a correct page or outputting a 404 page.
This is for SEO purposes to allow a nice URL like:
http://www.example.com/product
rather than
http://www.example.com/?p=product
I have this working on one sub folder of my blog but when trying to test it on a new project all i get is 500 errors as for ALL urls.
Here is the existing htaccess:
RewriteEngine on
RewriteBase /products/
RewriteCond %{HTTP_HOST} ^www.danclarkie.co.uk/products [NC]
RewriteRule ^(.*)$ http://danclarkie.co.uk/products/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !/admin.php$
RewriteRule .* index.php
Any help ^_^
Dan
currently i have a /en/ folder that is empty except for a .htaccess with the following
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ ../index.php?language=en$1 [NC]
i use it to eliminate the need for
index.php?language=en
in all my URLs. I would like to modify the htaccess in a way that i no longer need the /en/ folder with nothing but the htaccess inside. ideally i would like an htaccess in my root folder that reads the url and if it is www.example.com/en/ to rewrite to www.example.com/index.php?language=en
This should work for you:
RewriteRule ^en/(.*)$ index.php?language=en$1 [NC]
Put the following code in .htaccess file in your root folder.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^en/(.*)$ index.php?language=en$1 [L]
Here $1 will append rest of the url as well. The condition will also help if you request your files using direct url.