I am having error in the files.
This is my .htaccess file.
Redirecting error is mainly that it is showing a 404 error when I click login button then it redirects me to mydomain.com/login which shows me a 404 error as in the file ...
Options +FollowSymLinks -MultiViews
ErrorDocument 404 /warning/notfound
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^login$ login.php
</IfModule>
Options -Indexes
IndexIgnore *
Your question is not clear (to the least!) but here's the "translation" of your .htaccess file:
ErrorDocument 404 /warning/notfound if there's a 404 then redirect to /warning/notfound
RewriteCond %{REQUEST_FILENAME} !-d if the requested URL is not a directory then try to apply the next rule
RewriteRule ^(.*)/$ /$1 [L,R=301] Whatever is in the URL, if it ends with a / then remove it and stop URL rewriting rules (L = stop)
RewriteRule ^login$ login.php if the URL is login then redirect to login.php
Maybe the L is the source of your problem?
I hope I gave you enough clues to solve your problem!
Okay Now I have the answer actually there should be a slash here ..
RewriteRule ^login$ /login.php
This just solved my problem ...
Related
I have a wordpress site with the following configuration for the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I want to return a 410 error for some pages that were deleted.
I have tried adding the following lines, but the continue to return 404 rather than 410:
RewriteRule ^/somepage\.asp$ - [G,NC]
RedirectMatch gone "/somepage\.asp$"
RedirectMatch gone "\.asp$"
RedirectMatch gone ".*\.asp$"
Each of those returns a 404 error rather than the desired 410. I was testing by accessing it like this:
www.example.com/somepage.asp
I was able to get it to work by adding this line:
ErrorDocument 410 default
BTW: If someone wants to elaborate on why this works and add it as answer will accept it rather than accepting my own answer.
I would like to rewrite my URL only when typing this:
www.domain.com/dir1/dir2/dir3/
in that path there is a index.html file that will be automatically loaded. And I'd like it to become this:
www.domain.com/index.html
It is important that the root www.domain.com does not redirect to that subdirs because it already redirects to another .php file.
I wrote the following .htaccess file:
RewriteRule ^dir1/dir2/dir3/(.*)$ dir1/dir2/dir3/$1 [L]
but it redirects even when typing the root domain.com.
Could you help me with that?
Edit:
I have tried in another browser and the real problem is that when typing domain.com/dir1/dir2/dir3 or domain.com/dir1/dir2/dir3/index.html the dir1/dir2/dir3/ is still shown and is not hidden.
Edit 2:
my complete .htaccess:
AddHandler application/x-httpd-php56s .php
ErrorDocument 404 /404/404.html
ErrorDocument 500 /404/404.html
RewriteEngine on
RewriteBase /
Options -Indexes
RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ /404/404.html [R=404,NC,L]
RewriteCond %{REQUEST_URI} ^/500/$
RewriteRule ^(.*)$ /404/404.html [R=500,NC,L]
Thanks
Replace your current code with this:
DirectorySlash On
RewriteEngine On
# skip all known resources from rewrite rules below
RewriteRule \.(?:jpe?g|gif|bmp|png|ico|tiff|css|js)$ - [L,NC]
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+dir1/dir2/dir3/(\S*) [NC]
RewriteRule ^ /%1 [R=301,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^(?!dir1/dir2/dir3/)(.*)$ dir1/dir2/dir3/$1 [L,NC]
Wasnt sure what to put in the title to describe what is going on, but I was looking at ways I could deny direct access to files and folders. I added a line in .htaccess which didnt work so I removed it.
I have access to every page on my website, but index redirects me to the page I tried to prevent direct access to. I have deleted the content of .htaccess, index and the page im been redirected to, restarted wamp and used CTRL + F5 but nothing seem to work. No cookies are stored and no errors in inspect element.
This is my .htaccess file
Options -MultiViews +FollowSymlinks
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^http://example.com$ [NC]
#ERROR CODE -----------------------------------------------------------
ErrorDocument 400 /assets/error/400.php
ErrorDocument 401 /assets/error/401.php
ErrorDocument 403 /assets/error/403.php
ErrorDocument 404 /assets/error/404.php
ErrorDocument 500 /assets/error/500.php
RewriteRule ^400/?$ /assets/error/400.php [NC,L]
RewriteRule ^401/?$ /assets/error/401.php [NC,L]
RewriteRule ^403/?$ /assets/error/403.php [NC,L]
RewriteRule ^404/?$ /assets/error/404.php [NC,L]
RewriteRule ^500/?$ /assets/error/500.php [NC,L]
#User Pages-------------------------------------------------------
RewriteRule ^//?$ /index.php [NC,L]
RewriteRule ^signin/?$ /signin.php [NC,L]
RewriteRule ^signup/?$ /signup.php [NC,L]
RewriteRule ^signout/?$ /signout.php [NC,L]
RewriteRule ^forgot-password/?$ /forgot-password.php [NC,L]
RewriteRule ^credits/?$ /credits.php [NC,L]
RewriteRule ^leaderboard/?$ /leaderboard.php [NC,L]
RewriteRule ^updates/?$ /updates.php [NC,L]
RewriteRule ^live/?$ /live.php [NC,L]
#Misc--------------------------------------------------------------
RewriteRule ^misc/?$ /misc.php [NC,L]
RewriteRule ^maintenance/?$ /maintenance.php [NC,L]
#Maintenance-------------------------------------------------------
# files to load
# RewriteCond %{REQUEST_URI} !/assets/css/main.css$
# RewriteCond %{REQUEST_URI} !/assets/css/special.css$
# RewriteCond %{REQUEST_URI} !/maintenance.php$
# RewriteCond %{REQUEST_URI} !/.htaccess$
# here filter the developer's IP/
# RewriteCond %{REMOTE_HOST} !^212.251.187.11
# redirect page (maintenance page)
# RewriteRule $ /maintenance [R=302,L]
Edit
The problem seem to be occurring when I use example.com or example.com/, but not when using example.com/index.php.
There is only 1 .htaccess file been used and I've not made any changes to the apache files (atleast not my self), Im trying to find the .htaccess snippets I tried right before this started happening
I transfered my root folder to a different pc and everything works. I'm not sure what went wrong but I was not able to fix the problem. I'm reinstalling wamp to see if that solves the problem. I belive this is the code that I used before index stopped working Redirect 301 /old/file.html http://yourdomain.com/new/file.html I never replaced any of it with the index but with a 404 page and the page I was been redirected to.
The snippet was taken from:
http://viralpatel.net/blogs/21-very-useful-htaccess-tips-tricks/
i'm using laravel 5.0 on my server. i've just uploaded some images to my public/uploads folder.
But when i try to access them eg. /uploads/image.jpg, i'm receiving a 404 Not Found error.
Additionally my firefox browser says "Page is not redirecting properly" when i try to access just the "/upload/" folder(where i think it should be saying 403 forbidden or something).
how can i solve this problem? heres my .htaccess file :
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I think the problem for "The page isn't redirecting properly" is the follwoing line in your code:
RewriteRule ^(.*)/$ /$1 [L,R=301]
change it to this line :
RewriteRule ^/$(.*) /$1 [L,R=301]
the other code works fine for me .
I want to be able to enter the following into the URL:
https://mydomain.com/fork
or
https://mydomain.com/fork/
And for both to goto a subfolder called
https://mydomain.com/prod/fork_contents/index.html
But still only display https://mydomain.com/fork (or https://mydomain.com/fork/, either way)
I would like index.html to act as the root so all the image urls, etc still work (they are relative to '/prod/fork_contents/')
Currently the .htaccess in the root is:
ErrorDocument 404 /live/site_documents/document404.html
ErrorDocument 403 /live/site_documents/accessDenied.html
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^fork$ /fork/index.html [L,QSA]
RewriteRule ^fork/$ /fork/index.html [L,QSA]
RewriteRule ^fork/(.*)$ /prod/forklift_contents/$1 [L,QSA]
https://mydomain.com/fork/ Works fine!
https://mydomain.com/fork Doesn't work. The index.html loads, but it can't find any of the files. Firebug's net panel reports the following 'https://mydomain.com/css/style.css not found'. So the second case (without the trailing /) doesn't seem to know to go into https://mydomain.com/fork/css/style.css.
Thoughts?
You can use the question mark for optional charters
RewriteRule ^fork\/? /prod/fork/$1 [L]
For a very good tutorial on rewriting check this website
.htaccess tips and tricks..