I activate the SSL certificate and enable force redirection via c-panel to https but now my websites didn't open it says 403 Access is forbidden to the requested page errors on my website.
But when i disable force redirection then it works but only for http not for https.
HTTP works but HTTPS not working.
i also check permissions 644 for file and 755 for directories.
and here is the code in my .htaccess file
#Custom default index page
DirectoryIndex index.php
I also add these lines but didn't work
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
when i add these lines in .htaccess file the https urls shows something related to the server/domain hostpapa.
when i click on my website url it redirect me to https urls from http but it shows nothing just 403 forbidden error.
I have an .htaccess file defined at www.mydomain/documentation/.htaccess and am trying to redirect a number of broken links to a specific page.
The .htaccess file contains the Rewrite Rule
RewriteRule ^/?(documentation/PresentationCore~System\.Windows\.RoutedEventArgs).*$
/documentation/v4.x/SciChart_WPF_v4_SDK_User_Manual.html [R,L,NC]
Note: RewriteEngine ON has already been defined. Other rules are being applied
Now in .htaccess tester the rule is being evaluated and redirects correctly when the following URL is requested:
www.mydomain.com/documentation/PresentationCore~System.Windows.RoutedEventArgs~Handled.html
However, when the same domain is entered into the browser, I get a 404 not found for this page.
I can confirm I have uploaded .htaccess to the correct folder and cleared the server cache.
Is there anything else I need to do to get this to work?
You dont need to match the folder name if htaccess is already in that folder, try :
RewriteRule ^/?(PresentationCore~System\.Windows\.RoutedEventArgs).*$
/documentation/v4.x/SciChart_WPF_v4_SDK_User_Manual.html [R,L,NC]
I need to redirect from http://mysite/component/users to main page
i tried this rule in .htaccess but code not working.
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule http://mysite/component/users/ index.php [F]
but i need to keep from redirecting this page
http://mysite/component/users/?view=reset
it's possible ?
There's a couple of things fundamentally wrong with your RewriteRule:
When you use the F flag you can't rewrite the URL. The substitution is ignored.
The RewriteRule pattern is a regular expression and matches against the URL-path, not the absolute URL.
In order to return a 403 and display the appropriate content, you could either:
Internally rewrite to index.php and conditionally return a 403 Forbidden header.
or
Serve your 403 error document (using the F flag) and conditionally show your content?
However, I would simply serve the appropriate 403 error document and link to the homepage. The request is after all forbidden....
RewriteCond %{QUERY_STRING} !^view=reset
RewriteRule ^component/users/ - [F]
The above sends a 403 to all requests for URLs that start /component/users/, excluding those that have the query string view=reset.
I have a site sub.domain1.com
But i would like to access to it from the following url: domain2.com/folder
Here is the .htaccess file in domain2.com
RewriteEngine on
RewriteBase /
RewriteRule ^folder/(.*) http://sub.domain1.com/$1 [L,R=301]
This redirection works well but i wouldn't like to change the url to sub.domain1.com
I want to display the content of sub.domain1.com by using the url domain2.com/folder without changing url.
Thanks in advance
I want to redirect any 403 using .htaccess, but it does not seem to work.
Options +FollowSymlinks
RewriteEngine on
ErrorDocument 403 notfound.html
RewriteRule notfound.html
All help appreciated.
Thanks
Jean
The URL part of an ErrorDocument directive should either start with a leading slash, which indicates a path that's relative to your DocumentRoot, or it should be a full URL (if you want to use an external document).
You shouldn't need the RewriteEngine and RewriteRule directives at all here.
So, assuming your notfound.html is at the root level of your site, your directive should look like:
ErrorDocument 403 /notfound.html
I found a problem with the earlier example, which was:
ErrorDocument 403 /notfound.html
I have a directory on my site storing images, say at domain.com/images
I wanted that if someone tries accessing the directory's URL that they be redirected to the site's homepage. My problem was, with the above, that the URL in the browser would remain domain.com/images and then the homepage would load, but the homepage would reference stylesheets that it could not access from that URL. (And it makes sense - 403 is supposed to show an error message).
I then tried researching how to redirect a 403 error to another URL and a few sites said you can't do a 302 or 301 - you're missing the point: 403 is an error, not a redirect.
But I found a way. This is the .htaccess file inside the /images directory:
Options -Indexes
ErrorDocument 403 /images/403.php
RewriteEngine on
RewriteRule ^403.php$ /index.php [R=301]
So basically the first line prevents directory listing.
The second line says that for "permission denied" (ie. 403 error, which is what the first line gives), the site should load the file "/images/403.php". But you don't actually need to create any 403.php file in that directory, because...
The third line turns on your redirect engine
And the fourth line says that if the user attempts to load the page 403.php (ie. in this "/images" directory where this .htaccess file is located) then they should be redirected, using a 301 (permanent) redirect, to /index.php - which is the index of the root directory (ie the homepage), and not the index of the /images subdirectory (and indeed there is no index in "/images" anyway).
Hence - how to get a 403 to redirect to another URL using a 301 (permanent) redirect (or, you could try a 302 temporary redirect too).
Here is a super easy way to do this:
Use this line
Options -Indexes
ErrorDocument 403 /goaway.html
where goaway.html contains the following line in the head section:
<meta HTTP-EQUIV="REFRESH" content="0; url=HERE YOU PUT THE URL YOU ARE REDIRECTING TO" />
And that's it... each 403 error will go to your goaway.html file in root directory and goaway.html will redirect them to the URL of your choice
RewriteEngine On
ErrorDocument 403 http://www.yourdomain.example/