I have this one .htaccess:
RewriteEngine on
RewriteCond %{request_filename} -f
RewriteRule ^(.*) $1 [L]
RewriteRule ^(([^/]*)+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&q=$3 [L]
Now I want to upload separate scripts to the beta/ folder, what I must change in .htaccess for right working script in beta/ folder separately?
You can use:
RewriteEngine on
RewriteCond %{request_filename} -f
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} !^/beta/ [NC]
RewriteRule ^(([^/]*)+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&q=$3 [L]
The simplest approach would be to create another .htaccess and put it your beta/ folder. It'd then can override what's "parent" .htaccess set.
Related
I have my htaccess and it already does couple of good things (it hides www and .php in my url) but I also need to add one additional feature to it.
I have the main domain called: wdd.ie
I have a root folder called: wdd.ie
Most important files are kept in the root.
I have also the following file in the root: about.php
I love to access about.php file by calling non existing directory: www.wdd.ie/myweb/
And my full URL path looks like this: www.wdd.ie/myweb/about
I would like to access the file (stored in the root) to allow non existing directory in url but to ignore it
Could anyone help!? Please, please help!
As this new desired htaccess feature complexity is now probably beyond my skills.
<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ / [L,QSA]
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
</IfModule>
If I've understood correctly you want the following url www.wdd.ie/myweb/about to offer up content from www.wdd.ie/about.php but keep the url the same?
If so, then the following should work
RewriteRule ^myweb/about$ /about.php [L]
I have a website with the root folder 'www', but I put all php files including index.php in a sub-folder of root.
I wrote myself a .htaccess file to redirect, so if I input www.test.com, it will jump to www.test.com/folder and display the index.php.
Below it's my .htaccess which I put in the root.
RewriteEngine On
RewriteBase /
RewriteRule ^folder2 - [L]
#ignore folder2 in which I put important files, but no works for the website
RewriteCond %{REQUEST_URI} !^/folder(.*)
RewriteRule (.*) /folder/$1
Right now, I want to change the .htaccess file to reach these goals:
When I input www.test.com, jump to www.test.com/folder as usual, but display the url without folder.
All the pages in folder will display the url without folder name.
Such as
www.test.com/shop/page1 -> www.test.com/page1
I searched some of the scripts, but none of them works.
I've found this related question which answers to your problem. The snippet from the answer is (note: it's adjusted to your needs):
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+folder/([^\s]+) [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (?!^folder/)^(.*)$ /folder/$1 [L,NC]
Reference: https://stackoverflow.com/a/18361995/3673491
You can use below code.
RewriteEngine On
RewriteBase /
RewriteRule ^/?$ /folder/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /folder/$1 [L]
Based on your current rules. You can just make a slight adjustment.
RewriteEngine On
RewriteBase /
#ignore folder2 in which I put important files, but no works for the website
RewriteRule ^folder2/? - [L]
RewriteRule ^/?$ /folder/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /folder/$1 [L]
I am using codeigniter php framework. I am trying to access a folder under public_html, but I can't get to it. It shows 404 custom page by codeigniter. Does the following script in .htaccess has something to do with it?
RewriteEngine on
RewriteCond $1 !^(index\.php|js|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Thanks
It probably is, you can try adding either some conditions:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|js|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Or include your folder as part of the exclusion (example, your folder is "foobar"):
RewriteEngine on
RewriteCond $1 !^(index\.php|js|images|robots\.txt|foobar)
RewriteRule ^(.*)$ /index.php/$1 [L]
I am using the following .htacces file in my domain root.
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|admin|cache)
RewriteRule ^(.*)$ index.php [L]
One problem, is when I try to open the file located at cache/themes/theme1/global.css
But for some reasons it doesn't exclude the folder cache from the RewriteRule
Anyone know a solution for this?
I didn't test this but should work;
RewriteEngine on
RewriteRule ^(cache.*)$ $1 [L]
RewriteCond $1 !^(index\.php|images|robots\.txt|admin|cache)
RewriteRule ^(.*)$ index.php [L]
I want that every user has a profile-url like this:
www.example.com/username
I have created this htaccess:
RewriteEngine on
RewriteRule ([^/]+) profile.php?username=$1 [L]
but I get error with the css and js files.
what I have to write in the htaccess ?
You should in general exclude all real files and directories, as this will handle css/js/images/whatever else you want to serve:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ profile.php?username=$1 [L]
Exclue js and css with RewriteCond.I think this should do:
RewriteEngine On
RewriteCond %{REQUEST_URI} ! \.(js|css)$ [NC]
RewriteRule ([^/]+) profile.php?username=$1 [L]
If you have images as well, add their extensions
RewriteCond %{REQUEST_URI} ! \.(js|css|jpg|gif|ico|png|whatever)$ [NC]