LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-28-2010, 10:56 PM   #1
loganbest
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Rep: Reputation: 0
.htaccess not working in CentOS 5.5 x86_64


I have checked and double checked the .htaccess and httpd.conf to make sure everything is correct and I'm sure it is. I have AllowOverride set to All in the httpd.conf, Apache sees and is reading the .htaccess because I get a 500 Error when I put garbage text in the file. I'm lost now.

Last edited by loganbest; 09-28-2010 at 11:08 PM.
 
Old 09-29-2010, 12:04 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Hi,

Could you tell us what you want to do and post the .htaccess that is not working

Regards
 
Old 09-29-2010, 07:41 AM   #3
loganbest
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 0
I set up my site so that it can be put in any directory on the server, it just needs to be declared in the .htaccess

Code:
#----------------------------------------------------------------------------------------#
<Limit GET>
	order allow,deny
	allow from all
</Limit>
#----------------------------------------------------------------------------------------#

#----------------------------------------------------------------------------------------#

# uncomment this line to enable site wide gzip to increase load times
# may cause 500 server errors on servers running php in cgi mode
#---------------------------------------- GZIP BEGIN ------------------------------------#
#php_value output_handler ob_gzhandler
#---------------------------------------- GZIP END --------------------------------------#

#--------------------------------------- START SEO --------------------------------------#
Options +FollowSymlinks
RewriteEngine On


RewriteBase /beta


RewriteRule \.(css|jpe?g|gif|png|flv|swf)$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Main Menu Links #
RewriteRule ^videos/load/([^/]*)$ seemore.php?load=$1 [L]
RewriteRule ^videos/load/([^/]*)/([^/]*)$ seemore.php?load=$1&page=$2 [L]

RewriteRule ^audios/load/([^/]*)$ audio.php?load=$1 [L]
RewriteRule ^audios/load/([^/]*)/([^/]*)$ audio.php?load=$1&page=$2 [L]

RewriteRule ^audio/album/([^/]*)/([^/]*)$ audio.php?album=$1 [L]
RewriteRule ^audio/album/([^/]*)/([^/]*)/([^/]*)$ audio.php?album=$1&page=$3 [L]

RewriteRule ^blogs/load/([^/]*)$  blogs.php?load=$1 [L]
RewriteRule ^blogs/load/([^/]*)/([^/]*)$ blogs.php?load=$1&page=$2 [L]

RewriteRule ^albums/load/([^/]*)$ albums.php?load=$1 [L]
RewriteRule ^albums/([^/]*)/([^/]*)$ albums.php?load=$1&page=$2 [L]

RewriteRule ^people_ajax people_ajax.php [L]
RewriteRule ^people/([^/]*)/([^/]*)$ people.php?load=$1&page=$2 [L]
RewriteRule ^people people.php [L]
RewriteRule ^upload-media upload.php [L]

RewriteRule ^groups$ groups.php [L]
RewriteRule ^search search.php [L]


# Action Links #
RewriteRule ^videos/([^/]*)/([^/]*)$ play.php?vid=$1 [L]
RewriteRule ^audio/([^/]*)/([^/]*)$ play_audio.php?audio=$1

RewriteRule ^category/([^/]*)$ category_home.php?cid=$1 [L]
RewriteRule ^category/([^/]*)/([^/]*)$ category_home.php?cid=$1&page=$2 [L]

RewriteRule ^subcategory/([^/]*)/([^/]*)$ category_home.php?sub=$1 [L]
RewriteRule ^subcategory/([^/]*)/([^/]*)/([^/]*)$ category_home.php?sub=$1&page=$3 [L]

RewriteRule ^genre/([^/]*)$ genre_home.php?cid=$1 [L]
RewriteRule ^genre/([^/]*)/([^/]*)$ genre_home.php?cid=$1&page=$2 [L]

RewriteRule ^view-album/([^/]*)/([^/]*)$ album_view.php?album=$1
RewriteRule ^view-image/([^/]*)/([^/]*)$ album_view.php?image=$1
RewriteRule ^read_blog/([^/]*)/([^/]*)$ read_blog.php?id=$1 [L]

RewriteRule ^blogs/category/([^/]*)/([^/]*)$ blogs.php?cat_id=$1 [L]
RewriteRule ^blogs/category/([^/]*)/([^/]*)/([^/]*)$ blogs.php?cat_id=$1&page=$3 [L]

RewriteRule ^members/([^/]*)$  memberprofile.php?user=$1 [L]

#-------------------------------------------------------------#
# redirect directory browsing attempts
RewriteRule ^videos(.?)$ 	seemore.php [L]
RewriteRule ^audios(.?)$ 	audio.php 	[L]
RewriteRule ^blogs(.?)$ 	blogs.php 	[L]
RewriteRule ^members(.?)$	people	[R=301]
RewriteRule ^albums(.?)$ 	albums.php [L]

#-------------------------------------------------------------#

#--------------------------------------- END SEO ----------------------------------------#


#--------------------------------------- SOME SIMPLE BLOCKS -----------------------------#
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteCond %{QUERY_STRING} SELECT(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} UNION(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteRule ^(.*)$ index.php [F,L]
#--------------------------------------- END BLOCKS -------------------------------------#

Options -Indexes

<IfModule mod_security.c>
	SecFilterEngine Off
	SecFilterScanPOST Off
</IfModule>

ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
 
Old 09-29-2010, 08:59 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Hi,

Sorry, but I cannot check such complex rewrite rules, but at least the simple ones (like those for redirect directory browsing attempts)
Quote:
RewriteRule ^videos(.?)$ seemore.php [L]
RewriteRule ^audios(.?)$ audio.php [L]
RewriteRule ^blogs(.?)$ blogs.php [L]
RewriteRule ^members(.?)$ people [R=301]
RewriteRule ^albums(.?)$ albums.php [L]
work as expected.
If they don't work for you, check if you set AllowOverride to none inside a vhost or something like that.
You can also enable RewriteLog and see what happens with the rules that are not working

Regards
 
Old 09-29-2010, 09:22 AM   #5
loganbest
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 0
AllowOverride isn't in any of my vhost declarations, but the others I have set to All. It's not ever reading the RewriteBase, That's the biggest issue.
 
Old 09-29-2010, 11:24 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Edit .htaccess, leave just the 5 rules above and see if they work.
And of course enable rewrite logging and watch the rewrite.log when you visit a URL that should be redirected somewhere else.
 
Old 09-29-2010, 11:43 AM   #7
loganbest
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 0
I just put this in my httpd.conf under the vhost for the IP for this domain and that file doesn't get created at all

RewriteLog "/home/whatego/public_html/rewritelog.log"
RewriteLogLevel 9
 
Old 09-29-2010, 11:51 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Could be that the apache user does not have write permission in that directory. Or since you're running Centos, it could be SELinux preventing the log file to be created.
Why don't you put the rewrite logs into the same directory as the other apache logs?
 
Old 09-29-2010, 12:02 PM   #9
loganbest
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Just tried /var/log/httpd/rewrite_log and still no go. And SELinux is disabled already.
 
Old 09-29-2010, 12:33 PM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Try this variation:
Code:
<IfModule mod_rewrite.c>
RewriteLogLevel 9
RewriteLog /var/log/httpd/rewrite_log
</IfModule>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
.htaccess issue - CentOS JDMs14 Linux - Security 4 09-15-2009 04:20 PM
LXer: Xen 3.2 on CentOS 5.2 x86_64 / RHEL 5.2 x86_64 LXer Syndicated Linux News 0 07-12-2008 05:51 PM
k3b doesn't run on Centos 5 x86_64 dralexpe Linux - Software 7 08-05-2007 11:37 AM
3495 wifi not working on CentOS 5 x86_64 dwschulze Linux - Laptop and Netbook 1 07-26-2007 01:01 PM
CentOS 4 (x86_64 or i386) Mithrilhall Linux - Newbie 2 07-14-2006 10:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration