I'm using firebase hosting and i googled and htaccess is not supported this is my htaccess how do i convert it to firebase:
RewriteEngine on
RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
i tried nothing i just googled while development that it supports it and it appears to not support htaccess
Related
I'm working on my first symfony 4 project and i would like to upload it on my online server. My goal is to have it online on my domain to test it before a preview with my client.
I tried to put my files on the www folder (by ftp) and add a .htaccess in the main repository with :
<IfModule mod_rewrite.c>RewriteEngine On
# remove "www" from URI
RewriteCond %{HTTP_HOST} ^devfuzz\.(.+) [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
# force HTTPS
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# use public as starting point
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]</IfModule>
And i added a .htaccess in public with :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
I tried so many thing found on many forum but i have always the same with when i try to go on my website :
website view
How can i change this view to have a normal navigation like i had with :
php bin/console server:run in local
Try to change your code with this one :
# remove "www" from URI
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
You don't need to remove the www in this part of code, this code will do it for you so do NOT change it :)
I am helping out with a website that has a main/root website as well as a WordPress installation in a sub-directory. The .htaccess file of the main site has rules to redirect non-www traffic to www:
RewriteCond %{HTTP_HOST} ^site\.com [NC]
RewriteRule (.*) http://www\.site\.com/$1 [R=301,L]
However, this has no effect on the WP site. For instance:
site.com would redirect to www.site.com
site.com/some-content-belonging-to-root-site would redirect to www.site.com/some-content...
site.com/wordpress does not redirect to www.site.com/wordpress
I added similar rules to the WordPress .htaccess, playing around to try to get the result I would expect, but the best I could come up with is this:
RewriteCond %{HTTP_HOST} ^site\.com [NC]
RewriteRule (.*) http://www\.site\.com/wordpress/$1 [R=301,L]
...which successfully redirects site.com/wordpress to www.site.com/wordpress, but does not redirect site.com/wordpress/a-blog-post.
I feel like I must be missing something simple or obvious, but hours of experimentation and research have not yielded a thing except that .htaccess files in sub-directories are not advised (but I think this is unavoidable in this case).
I would be grateful for any suggestions on how to fix the rewrite condition or rule to successfully redirect the post links of the WP site.
Thanks!
EDIT / ADDITIONAL INFO: I modified the RewriteCond to better match the incoming URLs, thinking that this might help, but it has the same effect. The base wordpress URL is rewritten, but article URLs are not:
RewriteCond %{HTTP_HOST}/wordpress/.* ^site\.com/wordpress/.* [NC]
RewriteRule (.*) http://www\.site\.com/wordpress/$1 [R=301,L]
I wouldn't think that it should matter, but just in case, I'll mention that the article URLs look like this:
site.com/wordpress/2014/05/16/article-slug
It turned out that the problem was not the rewrite conditions or rules, but the order in which they appeared in the .htaccess file.
I read a WP forum post in which someone suggested moving the rewrites to the top of the file for performance reasons. I gave it a shot just to see what would happen and noticed that the URL for the articles was affected - not in a good way, but affected nonetheless. I got something like this:
www.site.com/wordpressindex.php?/2014/05/16/article-slug
There were some rewrite rules to rewrite the base and redirect to the index given a nonexistent directory or file, which was what was building the garbled URL above.
In case it happens to help anyone else, I began with a .htaccess file that looked like this:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
And ended up rearranging it to look like this, which now works to properly redirect all blog-related URLs to the www site:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{HTTP_HOST}/wordpress ^site\.com/wordpress [NC]
RewriteRule (.*) http://www\.site\.com/wordpress/$1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
Try:
RewriteCond %{HTTP_HOST} ^site\.com$ [NC]
RewriteRule (.*) http://www\.site\.com/wordpress/$1 [R=301,L]
And clean your browser history to make sure.
I also own a WordPress website and I was looking for www to non www redirect for my website : fasterthemes.com
The website is hosted in DigitalOcean and after struggling with several DAYS, I could figure out that all the solutions (.htaccess) codes available work fine if you've set the A record in your DNS settings properly. If it's not set then the redirection doesn't work !
So in my case,
I created one A record in my Digitalocean DNS like below :
i.stack.imgur.com/ie7f8.png
I added following code :
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.(.)$ [NC]
RewriteRule ^(.)$ http://%1/$1 [R=301,L]
And now as you can see if you browse http://www.fasterthemes.com , it redirects you to fasterthemes.com. Earlier it was throwing an error.
I hope this helps.
I'm facing an issue after migrating my blog from Blogger to Wordpress.
My all old links are properly redirecting to WP but there are few 404 errors in my Google Webmaster Tools account.
For example: www.bloggertipstricks.com/2013/03/seo-tips.html?m=1
There is an extra parameter added after the URL (?m=1). Anybody please help me to resolve this issue.
Here I got solution for this. As you know that Blogger also ends with ?m=0 with ?m=1 so you have to remove both from URLs. So try the below codes by adding them in the top of .htaccess file...
You you can use the following code in any version:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^m=1$
RewriteRule ^(.*)$ /$1? [R=301,L]
RewriteCond %{QUERY_STRING} ^m=0$
RewriteRule ^(.*)$ /$0? [R=301,L]
In Apache 2.4 and above you can use the following:
RewriteCond %{QUERY_STRING} m=[01]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [QSD,R=301,L]
In lower version of Apache then 2.4 you can use the following:
RewriteCond %{QUERY_STRING} m=[01]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI}? [R=301,L]
-Fresh install on a bluehost shared account
-I have read the document with the proposed solutions found here. Nothing worked.
When i hit: http://www.mydomain.com/wp-admin i get:
http://www.mydomain.com/wp-login.php?redirect_to=http%3A%2F%2Fwww.mydomain.com%2Fmydomain-com%2Fwww%2Fwp-admin%2F&reauth=1
it seems that it redirects me to the real subdirectory where my domain has the files. To achieve this my provider instructed to use this htaccess on the root of my accounts directory:
# Use PHP5.3 Single php.ini as default
AddHandler application/x-httpd-php53s .php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
RewriteCond %{REQUEST_URI} !^/mydomain-com/www/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /mydomain-com/www/$1
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
RewriteRule ^(/)?$ mydomain-com/www/index.php [L]
Some more info on the directory structure
www.mydomain.com is installed in /public_html/mydomain-com/www
wordpress is installed in the root of my www.mydomain.com thus: /public_html/mydomain-com/www
any ideas?
EDIT: The only way i find that works is to go directly to http://www.mydomain.com/wp-login.php
I found the solution here
The important stuff:
In WP directory's .htaccess file ,just below the line containing “RewriteEngine on”, add:
# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ /wp-admin/ [R=301,L]
I'm working on a wordpress site. And just installed SSL. It has been installed correctly but I want to redirect visitors to the https url for certain pages only. I also want to force browser to use http for other pages.
I know this can be done with .htaccess and tried several things as well. But unable to get this as I need. I'm a novice at handling .haccess rewrite rules and can't find the docs that can guide me.
For example, I need to force browser to use https for this two urls:
http://www.example.com/sells/payment/
http://www.example.com/customer/login/
and for all other urls to just use normal http forcefully. What kind of rules I need to write?
Update 1
I also have a rule that redirects non-www url to a www url, and that might be conflicting with these rules. Here is how I redirect all non-www urls to www urls.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
The issue I'm facing is, after applying https rules, it is redirected to https://www.www.example.com/sells/payment/ which is a wrong url.
Any idea for fixing this?
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(sells/payment|customer/login)/ - [E=MY_URL:1]
RewriteCond %{HTTPS} off
RewriteCond %{ENV:MY_URL} 1
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
RewriteCond %{HTTPS} on
RewriteCond %{ENV:MY_URL} !=1
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
UPDATE:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(sells/payment|customer/login)/ - [E=MY_URL:1]
RewriteCond %{HTTPS} off
RewriteCond %{ENV:MY_URL} 1
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
RewriteCond %{HTTPS} on
RewriteCond %{ENV:MY_URL} !=1
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
This what I've used consistently across my projects where I have similar use-cases as yourself:
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^(.+)$ - [env=askapache:%2]
# redirect urls with index.html to folder
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http%{ENV:askapache}://%{HTTP_HOST}/$1 [R=301,L]
# change // to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)//(.*)\ HTTP/ [NC]
RewriteRule ^.*$ http%{ENV:askapache}://%{HTTP_HOST}/%1/%2 [R=301,L]
This is an excerpt from a site where I found the solution, so I can't take credit for it:
Smart HTTP and HTTPS .htaccess Rewrite
I haven't tried it, but can you handle it the same way you do cononcial URLs?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com/your-page
RewriteRule (.*) https://www.example.com/your-page [R=301,L]