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.
Related
I have below code in my .htaccess file. When I open https://example.com/tran it shows 404 page but adding slash in url like https://example.com/tran/ works.
How can I make https://example.com/tran to redirect to https://example.com/tran/ and https://example.com/tran/parameter1 both work because also want to get parameter from url using $_GET method when it is available in url.
Options All -Indexes
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
<FilesMatch ".(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
Order Allow,Deny
Deny from all
</FilesMatch>
RewriteRule tran/(.*) transaction.php?id=$1
RewriteRule tran/(.*)/ transaction.php?id=$1
RewriteRule addr/(.*) address.php?id=$1
RewriteRule addr/(.*)/ address.php?id=$1
You can use:
RewriteRule tran(?:/(.*?)/?)?$ transaction.php?id=$1
RewriteRule addr(?:/(.*?)/?)?$ address.php?id=$1
instead of your 4 rules
I am NOOB. I am attempting to redirect specific IP addresses using htaccess to a different domain. Those ip addresses are of people copying what I type to describe stuff and put it on their site within a few hours. I want them to just see static site B while everyone else sees dynamic site A.
The code below is redirecting to cat.com which I used earlier as a test to redirect, which seemed to be working. But then I changed it to dog.com but but it is still redirecting me to cat.com. I had put a # symbol in front of the old rewriterule so it should not be in play anymore. I also checked the redirects in cpanel. This is a subdomain I am working with, not the main domain on the account. This htaccess file added only 68.14.155.149 to the redirects section nothing else.
<Files 403.shtml>
order allow,deny
allow from all
</Files>
# -- MOD: Forbid Cross Site Scripting in query
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^.*(allow_url_include|auto_prepend_file).* [NC]
RewriteRule ^(.*)$ - [F,L]
</IfModule>
# -- END MOD: Forbid Cross Site Scripting in query
deny from 180.76.5.0/24
deny from 198.23.76.220
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} ^38\.100\.121\.65$ [OR]
RewriteCond %{REMOTE_ADDR} ^206\.141\.173\.244$ [OR]
RewriteCond %{REMOTE_ADDR} ^68\.14\.15\0.24$
RewriteRule ^(.*)$ http://www.dog.com/$1 [L,R=301]
#RewriteRule ^(.*)$ http://www.cat.com/$1 [L,R=301]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^About\-us\.php$ About\-Me\.php [R=301,NE,QSA,L]
</IfModule>
#RVS END REDIRECT PAGE
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
Not sure how to fix this or replicate the error but it seems that sometimes my site goes into a 403 redirect error.
I've deleted cookies on my personal browser but it seems to enter 403 on other machines (on different IP's)
My hunch could be the htaccess file....
Can anyone spot anything odd with the following rules?
thanks....
<files .htaccess>
Order allow,deny
Deny from all
</files>
Options +FollowSymLinks
RewriteEngine On
#Options -Indexes
# All pages www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# below to force https
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [OR,NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.my-site.com%{REQUEST_URI} [NE,R=301,L]
I found out what it was - basically my DNS was set differently...I was using OpenDNS and it was messing up my personal UI experience...
This seems simple enough, but the documentation and search results on mod_rewrite are a bit lacking. In the interest of saving time, can someone explain to me the best way to direct my traffic?
If the url is /show/checkout I want https://servername.com/show/checkout. If the url is anything else, I want it to go to http://servername.com/show/whatever.
I've got mod_rewrite enabled. I am able to send all traffic to https, but I haven't succesfully filtered out /show/checkout traffic. This doesn't work because there is some insecure images/scripts that are causing security warnings in some browsers.
Thanks!
Current .htaccess that sends all traffic to https:
Order allow,deny
Allow from all
Deny from 65.208.151.
Options -Indexes
AddHandler fastcgi-script .fcgi
AddDefaultCharset UTF-8
AddDefaultCharset ISO-8859-1
DirectoryIndex index.cgi
RewriteEngine on
RewriteRule ^/(.*)$ http://myserver.com/$1 [R,L]
RewriteRule ^show/product/(.*)$ ?content=product;title=$1 [QSA,L]
RewriteRule ^show/(.*)/(.*)$ ?content=$1;nth=$2 [QSA,L]
RewriteRule ^show/(.*)$ ?content=$1 [QSA,L]
RewriteRule ^place/order$ ?email=order [QSA,L]
RewriteRule .htm$ /
This rule:
RewriteRule ^/(.*)$ http://myserver.com/$1 [R,L]
doesn't do anything, since URI's used to match on won't start with a /. Not just that, this rule is simply a redirect loop.
Remove that and try adding this:
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_REFERER} !show/checkout
RewriteCond $1 !^show/checkout
RewriteRule ^(.*)$ http://servname.com/$1 [L]
RewriteCond %{HTTPS} off
RewriteCond $1 ^show/checkout
RewriteRule ^(.*)$ https://servname.com/$1 [L]