i am running a site with joomla. It has a bunch of mod rewrite rules i don't totally understand.. as well as some kind of SEF link thing running.
i have a specific page named sched.html that i need to serve up and be completely ignored from the .htaccess.
I have tried everything i can possibly think of. including a number of recommendation from people in the Joomla forums and for the life of me i cannot get this working.
ANY help is appreciated!
You should have that line already in your .htaccess:
RewriteRule (.*) index.php
If not, post your complete .htaccess here.
Prepend this line with the following:
RewriteCond %{REQUEST_URI} !/sched\.html
The final result should look similar to this code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteCond %{REQUEST_URI} !^/sched\.html
RewriteRule (.*) index.php
Related
Currently I have the below rules in my htaccess file.
All files should redirect except if they have .htm or .html extensions
RewriteRule \.(htm|html)$ - [NC,L]
RewriteRule ^([A-Za-z0-9-+_./]+)/?$ index.php?page=$1&%{QUERY_STRING}
Now the problem is that tinyMce also has files with .htm, and in that case, the redirect should take place.
So, I want to prevent redirection on .htm files except when the folderstructure/url somewhere contains "tinyMCE" in it...
How can I do this?
Based on your shown samples could you please try following. Trying to fix OP's attempt here, please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !tinyMCE [NC]
RewriteRule ^([A-Za-z0-9-+_./]+)/?$ index.php?page=$1&%{QUERY_STRING} [L]
2nd solution: Or try with following rules too, please try to put ONLY one set of rules either above OR these ones at a time.
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!tinyMCE)[A-Za-z0-9-+_./]+)/?$ index.php?page=$1&%{QUERY_STRING} [L]
I just want to make the GET information that I sent:
http://mywebsite.com/folder/index.php?category=category-alias-here
http://mywebsite.com/folder/index.php?category=category-alias-here&page=5
To be rewrited on the URL bar as:
http://mywebsite.com/folder/category-alias-here/
http://mywebsite.com/folder/category-alias-here/5/
And I cant. Its very simple, I saw several similar questions. Tested several examples on stackoverflow and they all give me 404 for both category and both pages.
Here is a code that I tested:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ index.php?category=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ index.php?category=$1&page=$2 [L]
I understand that this code be wrong for my structure specifically, I tried several changes placing and removing ([^/]+) or changed the fist [L] to [N]. And several other things. But no luck with that.
Please notice, the whole website is inside a real directory (/folder/) and the .htaccess is also there (its not on root), once I launch the website everything will be on public_html, but I do not think this is the reason of this issue.
And yes, mod_rewrite is on. There is actually a .htaccess that I use, it works anywhere I place and it gets the category correctly but it is a bit messy.
Found a solution:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([a-z-]+)\/([0-9-]+)\/$ index.php?category=$1&page=$2 [NC,L]
RewriteRule ^([a-z0-9-]+)\/$ index.php?category=$1&page=$2 [NC,L]
I know that there are a bunch of answers for this question already on this forum and over the internet. But everything I tried is not working for me and I have no clue why. So that's why I'm asking this question.
I'm running a website with ExpressionEngine CMS. To remove index.php from the URL there is a small .htaccess rule which mentioned below and working fine.
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Everything running fine with this code in the htaccess file. But now I want to force www. in the URL because some AJAX scripts are not working when the URL is without www.. So I found some threads on this forum:
.htaccess - how to force "www." in a generic way?
https://expressionengine.stackexchange.com/questions/9853/site-doesnt-work-with-www-at-the-start-of-the-address/9864#9864
https in htaccess and order of rules (using Expression Engine)
The last has the most clear solution in my opinion so I added this to my .htaccess file.
# Add www.
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
My .htaccess file now looks like this:
RewriteEngine on
# Add www.
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# remove index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
This however give's me a ERR_TOO_MANY_REDIRECTS error.
I tried all other kind of methods but I keep getting this error and I don't know why. Everything I try to force www. through htaccess doesn't work or gives me this error.
What is going on? Is it possible that DNS settings have to do something with this?
You need to change it on Plesk control panel, you access the domain in question and change the non-www to www or set it to none.
The option you look for is located at subscription > Web Hosting Settings > Preferred Domain.
In case you set it to none then you can use the .htaccess rule.
This is the current Rewrite rule of Drupal set in my htaccess file:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_URI} !=/index.html
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
This works well, but the problem is that I want to have a custom page which will open when people browse to the website. More specific:
www.company.com/ should open index.html
All other pages should use the default rewriterule of Drupal.
I tried editing the DirectoryIndex, but then all pages are redirected to index.html.
DirectoryIndex index.html index.php
I also tried adding different Rewrite Rules but I didn't have any luck yet. Htaccess is not my best skill.
RewriteCond %{REQUEST_URI} ^/$ [NC]
RewriteRule ^/$ /index.html [L]
Probably there will be an easy solution, but I can't figure out what to do.
Does anyone know how to solve my problem?
Thanks!
Try adding to the rule the 301 code, meaning permanently moved.
RewriteCond %{REQUEST_URI} ^/$ [NC]
RewriteRule ^/$ /index.html [L,R=301]
I just moved my functional codeigniter project to a new web hosting provider and am now having challenges removing the index.php from the URL using a standard .htaccess mod-rewrite. Here is the .htaccess that was working fine:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I found this discussion but I do not have root access to the apache server to make the suggested configuration change.
Using the provided .htaccess file above,
Works fine: http://www.mysite.com/index.php/plans
Doesn't work: http://www.mysite.com/plans
Any suggestions are appreciated.
If you really have to accept both forms of URLs likewise then you need two RewriteRules. Once accepting variants with then 'index.php' part and one without.
Something like this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index\.php/(.*)$ index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Your question's not very clear, but a common problem with mod_rewrite rules like this is that some servers need the request to be passed as a query. I.e. you'd need to change your last line to:
RewriteRule ^(.*)$ index.php?/$1 [L]