Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I want to configure apache web server to prevent opening my website by ip address.
For example if my website is "domain.com" and my server ip is "111.222.333.444", you should not open my website by entering "111.222.333.444".
How can I do this?
Thanks for your help.
This should work in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
# block request by IP address
RewriteCond %{HTTP_HOST} ^111\.222\.333\.444$
RewriteRule ^ - [F]
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am new to apache web server.
I have a URL like :-
www.example.com/example1/{ dynamic string }/p123465/content
I want to convert it into:
www.example.com/example1/{ dynamic string }/pid/content
here dynamic string is different every time.
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^(example1/[^/]+)/p123465/(content)/?$ /$1/pid/$1 [L,NC,R]
Or if you already have /example1/.htaccess then use
RewriteEngine On
RewriteBase /example1/
RewriteRule ^([^/]+)/p123465/(content)/?$ $1/pid/$1 [L,NC,R]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I want to do case insensitive url redirection in nginx
Below is my code.
location ~* WapsiteDataFetch{
rewrite WapsiteDataFetch(.*) http://images.xample.com/xyz/images$1 permanent;
}
In the above case ,
www.example.com/WapsiteDataFetch is redirected properly to http://images.xample.com/xyz/images
however, the url "www.example.com/WAPSITEDATAFETCH" is not redirected properly.
Even if I Change a single character it is giving 404 error.
I have tried many blogs and seen many post from stack overflow and many of them have suggested "~*" but in my case it is not helping me.
please help me as I am stuck on this for a couple of days.
Use (?i) to match case-insensitively - http://perldoc.perl.org/perlretut.html
Location block is not necessary. Try this.
rewrite (?i)^/WapsiteDataFetch(.*) http://images.xample.com/xyz/images$1 permanent;
you can avoid using the regex engine twice, by doing the capturing inside the location block
location ~* WapsiteDataFetch(.*) {
return 301 http://images.xample.com/xyz/images$1;
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I've installed a photo script in a sub-folder(photos) on my site.
The script doesn't work when I go to www.domain.com/photos/ only works when i go to www.domain.com/photos/public/gallery/.
Can someone please help me with the code I would use in my .htaccess file to have www.domain.com/photos/ as the main link?
Thank You
Put this code in your DOCUMENT_ROOT/photos/.htaccess file:
RewriteEngine On
RewriteBase /aviation-photos/
RewriteRule ^$ public/gallery [L]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I have moved from a free blogging service to my own hosting. I don't have control full control over my old blog engine, but I can rewrite some links via theme creation facilities. That way, I plan to redirect my old users to my new site.
Links such as http://oldomain.com/post/post_id will be written as http://newdomain.com/http://olddomain.com/post/post_id because theming facilities doesn't allow me to get urls relative to root of site.
What I want to do is to redirect http://newdomain.com/http://olddomain.com/post/post_id to http://newdomain.com/post/post_id using a .htaccess file on my new domain.
How can I achieve this using a .htaccess file?
You can use:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+http://[^/]+([^\s]+) [NC]
RewriteRule ^ %1 [R=301,L,NE]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I want to 301 redirect to all my URLs who have a specific pattern.
Old URLs are like
http://www.example.in/1231/ask-meaning-in-hindi
http://www.example.in/1233/blow-meaning-in-hindi
http://www.example.in/1235/beyond-meaning-in-hindi
I want to redirect them to a pattern like this:
http://www.example.in/1231/ask
http://www.example.in/1233/blow
http://www.example.in/1235/beyond
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 ^([0-9]+/[^-]+)-.+$ /$1 [L,R=301]