my Redaxo CMS uses this .htaccess rule to route to the pages.
# treats symbolic links as pathname
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^/?redaxo/.*$
RewriteRule ^(.*)$ https://sample.com/index.php?%{QUERY_STRING} [L]
How can I achive this for IIS in a web.config ?
Related
Hello.
I have a site protected by a .htaccess which redirects everything to the /pb directory except the /cron directory which is directly accessible (later it will be protected).
My htaccess works (it redirects as I want) BUT I cannot load the .css .js files that I call directly into my index page.
Do I have to put a new .htaccess in my /pb directory to allow access to .css or can I do it in my root htaccess ? I do not understand.
My .htaccess file (the https lines can't be removed "hostinger")
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (www\.)?XXXXXXXXX.net
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^(cron) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^pb/ - [L]
RewriteCond %{DOCUMENT_ROOT}/pb/$1 -f
RewriteRule (.+) pb/$1 [L]
RewriteRule (.*) pb/index.php?path=$1 [L,QSA]
order deny,allow
deny from all
allow from XX.XXX.XXX.XX
Thanks for your help
First thing first, I have fixed your htacces rules file, comments have been made inside Rules file. Have your htaccess rules file like as follows style, make sure its placed in same folder where pb folder is there. Also please do clear your browser cache before testing your URLs.
Options -Indexes -MultiViews
RewriteEngine on
##Apply https rules here.
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?XXXXXXXXX.net [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
##Handling base URI of site.
RewriteRule ^/?$ pb/ [R=301,L]
##Blocking pb uri pages non existing ones.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^pb/ - [NC,L]
##making all uris which are files to pb folder.
RewriteCond %{DOCUMENT_ROOT}/pb/$1 -f
RewriteRule ^(.+)/?$ pb/$1 [L]
##Making non existing uris to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ pb/index.php?path=$1 [L,QSA]
order deny,allow
deny from all
allow from XX.XXX.XXX.XX
JS/CS rewrite/redirect:
You may need to use base tag to fix your js and other relative resources. If you are linking js files using a relative path then the file will obviously get a 404 because its looking for URL path. for example if the URL path is /file/ instead of file.html then your relative resources are loading from /file/ which is not a directory but rewritten html file. To fix this make your links absolute or use base tag. In the header of your webpage add this <base href="/"> so that your relative links can load from the correct location.
I changed the path in Drupal for a number of nodes and I need any external links that reference the old path to redirect to the new path. I don't know if path is the right word since everything is directed at index.php For example, the old ones were reached at http://domain.com/thepress/node/1111. In Drupal they've been changed to http://domain.com/thenews/node/1111. I need to redirect to the new uri any external urls that request those "pages" My .htaccess:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^thepress/([^.]+) thenews/$1
RewriteRule ^ index.php [L]
Any help is appreciated. I want to just strip the substring /thepress/ and replace it with /thenews/ and pass that to index.php for drupal to pull up the correct pages.
You need to redirect old URL to new one using R flag. Try these rules:
RewriteRule ^thepress/([^.]+)$ thenews/$1 [L,NC,R=302]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
I can't access directories on my host/server, after setting htaccess rewrite rules.
The rule is:
RewriteRule ^([A-Za-a0-9-]+)/?$ index.php?page=$1 [NC]
it's supposed to internally redirect http://domianname.com/index.php?page=login to http://domianname.com/login
but now i can't access directories on my server like http://domianname.com/admin.
What am i doing wrong?
You need rewrite conditions to skip files/directories from rewriting:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-a0-9-]+)/?$ index.php?page=$1 [L,QSA]
I am an .htaccess newbie and am having problems in removing a folder name from my sites URL.
It is currently: www.mydomain.com/engine
I have an expression engine site in a subfolder (named engine) of my hosts html folder. In this folder I have an htaccess document in which I have followed the directions in the expressionengine user guide to remove the index.php? from the URL succesfully, with:
RewriteEngine On
# Removes index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
I would now like to remove the "engine" referring to the subfolder from the URL too.
I have made numerous attempts going on advice in previous questions but have had no success.
On viewing www.mydomain.com, with any of my attempts I recieve:
Forbidden. You don't have permission to access / on this server.
I thought this could be a permissions problem, but this containing html folder has the same permissions as the "engine" folder which allows access.
Can anybody help with the .htaccess code i require?
yeh, the above rules don't apply to homepage url because it's a directory (doesn't pass the third RewriteCond), use the code below:
RewriteEngine On
# Removes index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond $1 ^$
RewriteRule ^(.*)$ /engine/index.php?/ [L]
I am having issues with htaccess redirections. Following is the issues I am having.
The root folder to which the main domain actually points has the following folder: "example"
example.com is actually internally linked to the path "root/example/" rather than "root/". This is done using the following htaccess code
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/example/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ example/index.html [L]
The folder "exmaple" has the following subfolders: newexample, newexample_beta
If I go to the URL "example.com/newexample", the URL needs to be internally linked to "root/example/newexample". But the URL redirects me to "example.com/example/newexample/"
could you please let me know what needs to be done