i wrote a framework using clean url with this structure /fa/site/controller/method/id.the problem is ckfinder integrated with ckeditor in upload and browse pictures use another type of url. i want to exclude these addresses fron rewiting may help to work.
my htaccess codes is
AddType text/css .css
<Files "*.js">
ForceType text/javascript
</Files>
RewriteEngine On
#RewriteCond %{REQUEST_FILENAME} ^/public/admin/plugins/ckfinder/ckfinder.html
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^.*$ index.php [NC,L]
#RewriteCond %{REQUEST_URI} !^/public/admin/plugins/ckfinder/1$ [OR]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
i am using wamp v. 2.4.17
comments are my tries to help the story but not helped.
any help is appreciated
Related
I want to redirect pages using .htaccess. I am using code igntiter
When user type this URL in addresss bar :
form.bixy.com/salesapp
and they hit enter button, the URL should changed into:
form.bixy.com/salesapp/administrator/addusr
I have this .htaccess inside the salesapp folder
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|images|stylesheets|system/application/sources/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/
</IfModule>
If the line RewriteRule ^(.*)$ index.php?/ is removed, I got The requested URL was not found on this server.
I have little knowledge about .htaccess. Any help is greatly appreciated, thanks in advance.
Edit:
This is my current .htaccess that I put inside salesapp folder:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|images|stylesheets|system/application/sources/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php [L]
RewriteRule ^/? /salesapp/administrator/addusr[NC,R=301,L]
</IfModule>
It still give me error, but the URL should've worked
The page isn’t redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
Inside salesapp you can try this .htaccess:
RewriteEngine on
RewriteBase /salesapp/
RewriteRule ^(?:administrator)?/?$ administrator/addusr [R=301,L,NC]
RewriteCond $1 !^(index\.php|images|stylesheets|system/application/sources/) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php [L]
I am unable to remove index.php from CodeIgnitor 3.0 URL. I have applied so many solutions but nothing worked. I am using WAMP 2.5 . rewrite_module is active in Apache . $config['index_page'] = ''. My htaccess file which is in the root folder is as follows
RewriteEngine on
RewriteBase /Reporting/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|js|img|css|captcha|robots\.txt)
RewriteRule ^(.*)$ /yourfolder/index.php/$1 [L]
Reporting is the folder in www where all the files are there.
I had problems with removing index.php with the default .htaccess code, but I managed and this is how my .htaccess looks like now.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
<Files "index.php">
AcceptPathInfo On
</Files>
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Try with this code in .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
You have this in Codeigniter documentation - READ
I have inherited a Prestashop website and the htaccess file is set up for all the required redirects. I want to allow access to the dev subdomain but the htaccess keeps redirecting to main site. I have tried to allow access with my limited knowledge and research from the web, but I get a 500 error when I upload the edited file.
the original rewrites are like so
<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.mysitename.com$
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{HTTP_HOST} ^www.mysitename.com$
RewriteRule ^.*$ - [NC,L]
RewriteCond %{HTTP_HOST} ^www.mysitename.com$
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404
I have tried to add at the beginning after
RewriteCond %{HTTP_HOST} ^www.mysitename.com$
these lines
RewriteCond %{HTTP_HOST} ^dev\.mysitename.com$
RewriteRule ^/(.*) http://dev.mysitename.com/index.php/$1 [L, QSA]
But I just keep getting a 500 error and can't experiment as it takes the site offline.
Your new lines are going between an existing RewriteCond and RewriteRule pair and breaking their syntax. Try moving your lines above the RewriteCond %{HTTP_HOST} ^www.mysitename.com$ line.
Have it this way:
<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.mysitename\.com$
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteCond %{HTTP_HOST} ^www\.mysitename\.com$
RewriteRule !(?:^|/)index\.php$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>
#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404
So I have:
-A mod_rewrite rule for a few things, including remove www., force https, and SEO
-A directory called stage that I want these rules to not apply to
Obviously as I'm posting here, the condition isn't being applied or met, and I have no idea why :(
A warning, I manually and automatically (using cPanel) manage my .htaccess, so it's pretty messy and I apologize sincerely in advance. I'd be very grateful if anyone could point out redundancy (I think I may see one but I'm unsure).
I appreciate any help anyone can offer me, even tips and not answers! I'm a beginner (relatively) and a software engineering student, so anything helps :) It may also explain my newbiness.
Here's my .htaccess file for the root public_html directory:
Thanks in advance :)
suPHP_ConfigPath /home/patters1/public_html
#AddType text/css .css
Options -Indexes
ExpiresActive On
ExpiresDefault "access plus 1 month"
# WEEK
<FilesMatch "\.(js|css|swf)$">
Header set Cache-Control "public, max-age=604800"
</FilesMatch>
RewriteEngine On
RewriteCond %{REQUEST_URI} !/selfcontrol
RewriteCond %{REQUEST_URI} !/myadmin
RewriteCond %{REQUEST_URI} !/stage
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+)$ index.php?a=$1
RewriteCond %{REQUEST_URI} !/selfcontrol
RewriteCond %{REQUEST_URI} !/stage
RewriteCond %{REQUEST_URI} !/myadmin
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?a=$1
RewriteCond %{HTTP_HOST} ^www\.pattersoncode\.ca$
RewriteRule ^/?$ "https\:\/\/pattersoncode\.ca\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^!.pattersoncode\.ca$
RewriteRule ^/?$ "https\:\/\/pattersoncode\.ca\/" [R=301,L]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [L]
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
RewriteCond %{HTTP_HOST} !^pattersoncode\.ca$
RewriteRule ^/?$ "https\:\/\/pattersoncode\.ca\/" [R=301,L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://pattersoncode.ca/$1 [R=301,L]
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
ErrorDocument 404 /resources/error.php?a=das
ErrorDocument 401 /resources/error.php?a=4sdfdsc
ErrorDocument 403 /resources/error.php?a=4fsd
ErrorDocument 500 /resources/error.php?a=500fdf
ErrorDocument 400 /resources/error.php?a=400dsf
I would recommend to check your .htaccess file with this tool by commenting all your lines and uncommenting it one rule at a time. There are many errors / typo / duplicate lines in your code.
Here are a few errors:
Here is a duplicated rule:
RewriteCond %{REQUEST_URI} !/selfcontrol
RewriteCond %{REQUEST_URI} !/myadmin
RewriteCond %{REQUEST_URI} !/stage
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+)$ index.php?a=$1
RewriteCond %{REQUEST_URI} !/selfcontrol
RewriteCond %{REQUEST_URI} !/stage
RewriteCond %{REQUEST_URI} !/myadmin
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+)$ index.php?a=$1
Here you wrote this but I think that you meant !^pattersoncode\.ca$:
RewriteCond %{HTTP_HOST} ^!.pattersoncode\.ca$
And you could have combine it with the previous condition
RewriteCond %{HTTP_HOST} ^www\.pattersoncode\.ca$ [OR]
RewriteCond %{HTTP_HOST} ^!.pattersoncode\.ca$
Why this rule should only work on port 80 contrary to the previous ones ?
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://pattersoncode.ca/$1 [R=301,L]
You should remove the " characters from this rule
RewriteRule ^/?$ "https\:\/\/pattersoncode\.ca\/" [R=301,L]
My site is a php based site, but I've added wordpress in a /blog/ folder. The .htaccess file below should allow the /blog/ folder to be accessed, but I get a 404 error saying that blog.php doesn't exist.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !\.(gif|jpg|png)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/(.*)/$ /$1_$2.php [L]
RewriteRule ^(.*)/$ /$1.php [L]
</IfModule>
Anybody able to help at all?
The last RewriteRule is redirecting your request to /blog/ to index.php, you should add a RewriteCond to check if the request is on the blog folder.
RewriteCond %{REQUEST_URI} !^/blog/.*
I managed this using the code below, for some reason the conditionals that were suggested don't work (I HATE .htaccess)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(blog) - [L]
RewriteCond %{SCRIPT_FILENAME} !\.(gif|jpg|png)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/(.*)/$ /$1_$2.php [L]
RewriteRule ^(.*)/$ /$1.php [L]
</IfModule>
Adding
RewriteRule ^(blog) - [L]
to public_html/.htaccess after
RewriteEngine On
worked for me as well on a fresh Wordpress installation with Fantastico on a Hostgator account, with a blog.example.com subdomain.