1

I have a PHP directory that uses some htaccess lines and some line is causing too many directs. At least the browser states that.

I think the problem is related to this line below in the htaccess file because when I comment that line, I get a 404, but I have no idea what is wrong: RewriteRule ^([a-zA-Z]+)\.html$ $1.php [L]

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


Options +FollowSymLinks
Options -MultiViews
Options All -Indexes


<IfModule mod_deflate.c>
<FilesMatch "\.(js|css)$">
    SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>


Header unset ETag
FileETag None
<FilesMatch "(?i)^.*\.(ico|flv|swf|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
Header set Expires "Fri, 21 Dec 2012 00:00:00 GMT"
Header set Cache-Control "public, no-transform"
</FilesMatch>

<FilesMatch "\.(htaccess|tpl)$">
  Order Allow,Deny
  Deny from all
</FilesMatch>

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^([a-zA-Z]+)\.html$ $1.php [L]



RewriteRule ^category\/(.+/)location/(.+)$ browse_categories.php?id=$1&location=$2 [L,NC,QSA]
RewriteRule ^category\/(.+)$ browse_categories.php?id=$1 [L,NC,QSA]



RewriteRule ^location\/(.+)$ browse_locations.php?id=$1 [L,NC,QSA]


RewriteRule ^pages\/(.+)\.html$ page.php?id=$1 [L,NC]


RewriteRule ^blog.html$ blog.php [L,NC,QSA]
RewriteRule ^blog\/([^/]+)-([0-9]+).html$ blog_post.php?id=$2 [L,NC]
RewriteRule ^blog\/category\/(.+)-([0-9]+).html$ blog.php?category_id=$2 [L,NC,QSA]


RewriteRule ^out-([0-9]+)\.html$ out.php?listing_id=$1 [L]
RewriteRule ^out-([0-9]+)-([0-9]+)\.html$ out.php?listing_id=$1&banner_id=$2 [L]



RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)\.html$ listing.php?id=$1 [L,NC]
RewriteRule ^([^/]+)/images\.html$ listing_images.php?id=$1 [L,NC,QSA]
RewriteRule ^([^/]+)/send-message\.html$ listing_email.php?id=$1 [L,NC]
RewriteRule ^([^/]+)/send-message-friend\.html$ listing_email_friend.php?id=$1 [L,NC]
RewriteRule ^([^/]+)/reviews\.html$ listing_reviews.php?id=$1 [L,NC,QSA]
RewriteRule ^([^/]+)/add-review\.html$ listing_reviews_add.php?id=$1 [L,NC]
RewriteRule ^([^/]+)/classifieds\.html$ listing_classifieds.php?id=$1 [L,NC,QSA]
RewriteRule ^([^/]+)/locations\.html$ listing_locations.php?id=$1 [L,NC,QSA]
RewriteRule ^([^/]+)/documents\.html$ listing_documents.php?id=$1 [L,NC,QSA]
RewriteRule ^([^/]+)/events\.html$ listing_events.php?id=$1 [L,NC,QSA]
RewriteRule ^([^/]+)/jobs\.html$ listing_jobs.php?id=$1 [L,NC,QSA]
RewriteRule ^([^/]+)/suggestion\.html$ listing_suggestion.php?id=$1 [L,NC]
RewriteRule ^([^/]+)/claim\.html$ listing_claim.php?id=$1 [L,NC]


RewriteRule ^classified/[^/]+-([0-9]+)\.html$ classified.php?id=$1 [L,NC,QSA]
RewriteRule ^classified/[^/]+-([0-9]+)/images\.html$ classified_images.php?classified_id=$1 [L,NC]


RewriteRule ^event/[^/]+-([0-9]+)\.html$ event.php?id=$1 [L,NC,QSA]


RewriteRule ^job/[^/]+-([0-9]+)\.html$ job.php?id=$1 [L,NC,QSA]


RewriteRule ^sitemap.xml$ xml.php?type=sitemap [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ 404.php?id=$1 [L,NC]

</IfModule>

I should see the page to which I am redirected.

Accountant م
  • 6,975
  • 3
  • 41
  • 61
MrNedas
  • 17
  • 3
  • 1
    Did you try to [debug the mod_rewrite](https://stackoverflow.com/questions/9632852/how-to-debug-apache-mod-rewrite) and see what is happening ? – Accountant م Aug 18 '19 at 00:58
  • Please remove all the stuff not related to your question from that file you posted. Such a wall of code will drive away most of the people otherwise willing to help you. You see, you need to make it easy for others to help you, that is _your_ responsibility. You cannot simply dump everything in fron of everyone's feet and expect people to be happy about that... – arkascha Aug 18 '19 at 18:39

0 Answers0