Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Pulling my hair out(whatever left of it)) .
I got some articles linking to my site like
<a href="http://www.blahblah.com/%20">blah</a> , well of course, Gbot is giving craw error. So I was trying to rewrite in .htaccess
RewriteRule ^/\%20$ / [R=301]
and other different things. But still didn't work out. So please expert help is needed.
Thanks in advance
Click here to see the post LQ members have rated as the most helpful post in this thread.
but it didn't work. In httpd access log, it showed "GET /%20 HTTP/1.1" 404. I also tried with
RewriteCond %{REQUEST_URI} ^/\%20 , but result was the same..
Are you sure you leave a blank space after the slash (/) in the RewriteCond? This is because apache turns %20 into a space.
You can check error_log to see why you get the 404 error.
#####301 redirect for url doesn't exist
###/index.php/it-service ...etc will be redirected to / including index.php
RewriteCond %{REQUEST_URI} ^/index.php$
RewriteRule (.*) / [R=301,L]
########################
RewriteCond %{REQUEST_URI} ^/index.php/(.*)
RewriteRule (.*) /error404.html [R=301]
I made test environment in my lan. I also created the html file with <a href="http://192.168.1.11/%20">test page</a> and restarted the server. And also clear the cache on browser, which accessing the page. On the access_log, I still got
When I check in error.log, I got
[client 192.168.1.4] File does not exist: /var/www/html/ . but i can go to webpage directly but typing ip address without even having index.php..
So Doc Root is set correctly in conf.
Strange...
It's strange indeed.
Are you sure apache reads .htaccess files? Put some garbage into .htaccess and see if you get a 500 error
Also the .htaccess must be located under the docroot (/var/www/html in your case)
It worked, I just put the code you suggested in production server and worked straightaway. Sorry for all the fuss, but some reason my test server is still not working.
I removed everything in .htaccess and wrote simple redirect a.html to b.html
RewriteRule ^a\.html$ b.html
And it didn't work. So somehow it is not reading htaccess.
If your test box doesn't read .htaccess files, you must make sure that you have:
Code:
AllowOverride All
inside the <Directory /var/www/html>...</Directory> stanza in httpd.conf
Quote:
It worked, I just put the code you suggested in production server and worked straightaway. Sorry for all the fuss, but some reason my test server is still not working.
If you feel that your question is answered, you can mark the thread as "Solved" from the "Thread Tools" on top of the page
Thanks again for your help. Unfortunately because of my stupid behavior, the other user name was banned. so I couldn't put solved in topic. But your help was most greatly appreciated and saved me a lot of hours.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.