I need some help please
I have installed LAMP on my Debian 7.1 VPS and there's no domain, just an IP.
When I try access my IP via browser, it says:
The [ive hidden the IP] page isn’t working
[ive hidden the IP] redirected you too many times.
I'm not exactly sure what to edit/remove in my .htaccess file to fix this.
This is what my .htaccess file looks like
RewriteEngine on
RewriteRule ^(\w+)$ index.php?page=$1 [L,NC,QSA]
RewriteRule ^(\w+)+\/$ index.php?page=$1 [L,NC,QSA]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
order allow,deny
deny from [some random ip address that i've hidden]
allow from all
I've removed www. from the last RewriteRule line because I'm using an IP address instead of a domain, did I do this correctly?
Thanks
Related
I am in a situation where an user can create his blog in a subdomain.
Users will create blogs and enter the address he wants like say,
abcd.domain.com Then my php code creates a directory called abcd.
To view the blog user will type in abcd.domain.com in his browser and I want a .htaccess code which will rewrite the url and open the files inside the domain.com/abcd
But for the user the url in the browser should stay abcd.domain.com
Currently I am trying this code
RewriteCond %{HTTP_HOST} ^test\.domain\.com$
RewriteCond %{REQUEST_URI} !^test/
RewriteRule ^(.*)$ /test/$1 [L,QSA]
But this gives me 404 even though I have a file test.html inside the test folder and trying to view that page.
Also in this situation I will have to manually make change to the .htaccess file for URL rewrite. What I want to know is if it is possible to have a wild card subdomain redirect to the respective directory.
You can use:
RewriteCond %{HTTP_HOST} ^test\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/test/
RewriteRule ^(.*)$ /test/$1 [L,QSA]
REQUEST_URI with leading /.
With wild card subdomain:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/%1/
RewriteRule ^(.*)$ /%1/$1 [L,QSA]
Note that it takes more than a rewrite rule to have wildcard subdomains. Just fyi.
You need to have created a wildcard DNS record for subdomains and also tell apache to use any subdomain request by having a ServerAlias of *.domain.com in the apache config.
Then try your rule this way and see if it works for you.
RewriteCond %{HTTP_HOST} ^((?!www).+)\.domain\.com$ [NC]
RewriteCond %1::%{REQUEST_URI} !^(.*?)::/\1/?
RewriteRule ^(.*)$ /%1/$1 [L,QSA]
OK, I have boonex script installed and the original .htaccess is on http://codeshare.io/zSQvq.
I want to redirect everyone to another directory on the server (whilst I build the site)
The only allowed will be my 2 IPs. And for that I added:
RewriteCond %{REMOTE_ADDR} !^(18\.13\.112\.222|18\.4\.144\.106)
RewriteCond %{REQUEST_URI} !^/inamoment/ [NC]
RewriteRule ^(.*)$ http:// mysite .com/inamoment/$1 [R=302,L]
after RewriteEngine on
and when I do that I receive a 500 Internal Server Error.
Is there maybe something contradictory?
Do you mind to have a look on http://codeshare.io/zSQvq
Many thanks
(http:// mysite .com/ was separated on purpose)
And everything works with:
RewriteCond %{REMOTE_ADDR} !^(192\.249\.19\.122|81\.13\.18\.56)
RewriteCond %{REQUEST_URI} !^/inamoment/ [NC]
RewriteRule ^(.*)$ http://site(dot)com/inamoment/$1 [R=302,L]
Where on the first line: I tell that if the visit is not from any of those IPs;
2nd and 3rd line: says to redirect to site.com/inamoment
All the best
Recently I have gone through my website with some SEO tools and they suggest that I remove my IP canalization using .htaccess file, but I don't know how to remove this using .htaccess file code.
What does this mean?
If that's the only domain that you host from your document root, then you can try adding these rules to the htaccess file in your document root:
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.neotericuk\.co\.uk$ [NC]
RewriteRule (.*) http://www.neotericuk.co.uk/$1 [R=301,L]
If there are other hosts that are also being hosted from the same document root, then you can match specifically for the IP address:
RewriteCond %{HTTP_HOST} ^neotericuk\.co\.uk$ [NC,OR]
RewriteCond %{HTTP_HOST} ^1\.2\.3\.4$
RewriteRule (.*) http://www.neotericuk.co.uk/$1 [R=301,L]
where 1.2.3.4 is your server's IP address.
My client has a godaddy Virtual Dedicated Server (yes I know it sucks).... It has WHM VPS Optimized running on it .
I am trying to remove the index.php from the urls but my server still displays 404 errors I have looked at every forum in the universe and cant get an htaccess file that works. Here is what expression engine tells you to put use...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^(/index\.php|/img|/js|/css|/robots\.txt|/favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
I know diddly about Apache.. please help kind sirs...
Test if the htaccess is working:
# Redirect domain
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$
RewriteRule ^/?$ "http\:\/\/google\.com" [R=301,L]
Or
# Remove the www from the URL
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Ensure you actually have content appearing when you enter /index.php :P
Once you know your htaccess is working try "$1" instead of "%{REQUEST_URI}":
RewriteEngine on
RewriteCond $1 !^(img|admin\.php|themes|robots\.txt|index\.php|sitemap\.xml|/favicon\.ico) [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]
Also try "/index.php?/$1" instead of "/index.php/$1"
Ensure you have set EE (Admin->General Configuration) so "Name of your site's index page" is blank.
Remember that once you do get EE to work without the index.php appearing, it can be used both ways (with and without), which is bad for SEO, so remove it like so (place before the above rewrite :)
# Redirect index.php Requests (prevent site showing index.php in browser address bar)
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]
I have a site, say www.test.com. Now I need to get see the site only by typing the IP address, i.e. 102.3.0.2/index.php.
For that, what I need to change in my htaccess file?
Following is my htaccess file code:
#Options +FollowSymLinks
RewriteEngine on
#RewriteBase /cash-flights/
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond $1 !(^index\.php|gif$|jpg$|jpeg$|JPG$|JPEG$|GIF$|PNG$|BMP$|png$|bmp$|js$|php$|htm$|html$|css$|ttf$|txt$|pdf$|swf$|flv$|robots\.txt$|video_chat$|.ico$)
#RewriteRule ^(?!js\/tinymce)(.*?)(\.html|\.php|\/)?$ index.php/$1 [NC,L]
RewriteRule ^(?!phpinfo\.php)(?!js\/tinymce)(?!turkeyMap)(?!cron_home)(?!quote_by_sms)(?!paypal)(?!supporttrio)(?!12all)(?!system\/application\/libraries\/libgmap)(.*?)(\.html|\.php|\/)?$ index.php/$1 [NC,L]
RewriteRule ^(.*)$ - [NC,L]
#php_value session.gc_maxlifetime 86400
<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from 100.200.200.200
Options -Indexes
Don't know if this is the reason why you are not getting it, but the ip has to be four numbers.
I.E. 102.1.10.1.
Any site name ex: www.test.com must be translated to an ip, if you can reach the site using a name you can also reach it using the ip address.
RewriteCond %{HTTP_HOST} !=123.456.789.101
RewriteRule ^(.*)$ http://123.456.789.101$1 [R,L]
But it can easily be bypassed by editing the value of the HOST HTTP header.