.htaccess problems on phplinkdirectory - php

I have just installed phplinkdirectoy.
I can view the home page fine.
But when I go to any other page I get a 500 server error.
I believe this is due to problems with my .htaccess file, as if I delete the .htaccess file I get a 404 error when going to anything other than the home page.
As an example, part of my .htaccess file looks like this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^submit$ index.php?controller=submit [QSA,NC,L]
I have tried making it look at the install directory on my server by changing it to this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^submit$ /other_sites/abc.example.com/index.php?controller=submit [QSA,NC,L]
n.b. /other_sites/abc.example.com/ is where the files are stored on my godaddy hosting account. The url of the directory is actually dir.gingercatgames.com
What am I doing wrong with my .htaccess file?
Update: The full .htaccess file is here:
#######################################################
## PHP Link Directory 5.x - Apache Server Settings ##
#######################################################
# Disable directory browsing
#Options -Indexes
# Follow symbolic links in this directory
#Options +FollowSymLinks
# Override PHP settings that cannot be changed at runtime
# (If your server supports PHP settings via htaccess you can comment following two lines off)
# php_value register_globals 0
# php_value session.auto_start 0
# Customized error messages
# ( If you are running in a subfolder please add it, example: "directory/index.php?httpstatus=404" )
#ErrorDocument 404 index.php?httpstatus=404
# Set the default handler
DirectoryIndex index.php
# URL rewrite rules
<IfModule mod_rewrite.c>
RewriteEngine On
#Make sure RewriteBase points to the directory where you installed phpLD.
#Example: "/phpld" if your installation is in a "phpld" subdirectory.
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^contactlisting index.php?controller=details&action=contactlisting [QSA,NC,L]
##Old Details Link Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*)detail/(.*)$ index.php?controller=system&action=detailsredirect&id=$2 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^detail.php index.php?controller=system&action=detailsredirect&id=$1 [QSA,NC,L]
##alphameric Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^alphameric/([A-Za-z]|0\-9)$ index.php?controller=alphameric&id=$1 [QSA,NC,L]
##Author Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^contact index.php?controller=contact [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^search/([^/]+) index.php?controller=search&action=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^search index.php?controller=search [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^latest index.php?controller=index&action=latest [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^top index.php?controller=index&action=top [QSA,NC,L]
#RSS
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^rss index.php?controller=index&action=rss [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^user/thankyou$ index.php?controller=user&action=thankyou [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^user/confirmed$ index.php?controller=user&action=confirmed [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^user/sendpassword$ index.php?controller=user&action=sendpassword [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^user/recovered$ index.php?controller=user&action=recovered [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^submit$ index.php?controller=submit [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^submit/confirmed$ index.php?controller=submit&action=confirmed [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^payment/([^/?]+) index.php?controller=payment&action=$1&%{QUERY_STRING} [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^payment index.php?controller=payment [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^user/submissions$ index.php?controller=user&action=submissions [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^user/register$ index.php?controller=user&action=register
##Author Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^login$ index.php?controller=user&action=login
##Author Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^logout index.php?controller=user&action=logout
##Author Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^user/profile index.php?controller=user&action=profile
##Author Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^user/([^/?]+) index.php?controller=user&action=$1&%{QUERY_STRING}
##Author Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^user index.php?controller=user&action=index
##Author Page Rewrite
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteCond %{REQUEST_FILENAME} !-l
# RewriteRule ^article/(.*)$ index.php?controller=article&idArticle=$1 [QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^tag/(.*)$ index.php?controller=tag&tag=$1 [QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^location/([\ 0-9a-zA-Z,_-]*)/(.*) index.php?controller=location&location=$1&category=$2 [QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^location/(.*)$ index.php?controller=location&location=$1 [QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^listing/comment/([0-9]*)$ index.php?controller=details&action=comment&idLink=$1 [QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^listing/rate/([0-9]*)$ index.php?controller=details&action=rate&idLink=$1 [QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^listing/(.*)/(.*)([/]*)$ index.php?controller=details&idLink=$2 [QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^listing/(.*)/(.*)([/]*)$ index.php?controller=details&idLink=$2 [QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^rules([0-9]*)$ index.php?controller=index&action=rules [QSA,NC]
##Author Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*)authors/author-(.*)\.htm[l]?$ index.php?controller=author&action=index&idUser=$2 [QSA,NC]
##Owner Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*)owner/owner-(.*)\.htm[l]?$ index.php?controller=author&action=index&idUser=$2 [QSA,NC]
##Pagination Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^page/(.*)([/]*)$ index.php?controller=page&action=index&name=$1 [QSA,NC,L]
RewriteRule ^(.*)loadingAnimation.gif$ javascripts/thickbox/loadingAnimation.gif
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^tellfriend index.php?controller=details&action=tellfriend [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^unauthorized index.php?controller=index&action=unauthorized [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^banned-massage index.php?controller=index&action=banned [QSA,NC,L]
##Old Details Link Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^detail/(.*)-([0-9]*)[\..*] index.php?controller=system&action=detailsredirect&id=$2 [QSA,NC,L]
## Domain.com/{link-type}/{title-of-link}-{link-id}.{html|.htm|.php}
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)/(.*)([/]*)\.(.*)$ index.php?controller=details&idLink=$2 [QSA,NC,L]
## Domain.com/{link-type}/{title-of-link}-{link-id}
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)/(.*)([/]*)$ index.php?controller=details&idLink=$2 [QSA,NC,L]
## Domain.com/{title-of-link}-{link-id}.{html|.htm|.php}
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)([/]*)\.(.*)$ index.php?controller=details&idLink=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^detail.php index.php?controller=system&action=detailsredirect&id=$1 [QSA,NC,L]
##Pages redirect
RewriteCond %{REQUEST_URI} !page-[0-9]+\.html?$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)\.html$ index.php?controller=page&name=$1 [NC,QSA,L]
##Category redirect
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
#<IfModule mod_fcgid.c>
# MaxRequestLen 1000000000
# IPCConnectTimeout 100
# IPCCommTimeout 1000
#</IfModule>

The 500 error sounds like either the result of a Multiviews setting, or not having mod-rewrite enabled in htaccess.
Try adding this at the top of your original htaccess:
Options -Multiviews
Also check that mod_rewrite is both installed and activated for htaccess files.
If you are not sure, to check if mod_rewrite is installed, look at the list of installed modules in the output of phpinfo();
By default, mod_rewrite is not enabled for htaccess files. If you are managing your own server, open httpd.conf
and make sure that the webroot directory block contains one of these lines: AllowOverride FileInfo or AllowOverride All

Related

htaccess RewriteRule also runs functions on other redirect page

When I go to my first url, example: website.be/festivalName/eventName then te script on the url, website.be/festivalName, runs.
What am I doing wrong?
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ views/festivals/index.view.php?organisation=$1&festival=$2&event=$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ views/festivals/index.view.php?organisation=$1&festival=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ views/organisations/index.view.php?organisation=$1 [L]

Htaccess file work only in a project

I am using the same code, but it work only on first project.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?pg=$1 [QSA,L]

how to change htaccess rule to make url with query string without trailing slash

I want to change some rules in .htaccess file write now my url is like this www.example.com/d/somthing.htm and some another pages with www.example.com/category.htm now i want to change them in this way www.example.com/index.php?d=somthing what i have to do.
My current .htaccess content are:-
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} ^/p\/[a-z][a-z]\/[[:print:]]+\.htm$
#RewriteRule \/p\/([a-z][a-z])\/([[:print:]]+)\.htm$ /index.php?p=$2&lang=$1 [L]
#RewriteRule \/p\/([a-z][a-z])\/([[:print:]]+)\.htm$ /index.php?p=$2&lang=$1 [L]
RewriteRule . /index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/p\/[[:print:]]+\.htm$
RewriteRule \/p\/([[:print:]]+)\.htm$ /index.php?p=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/s\/[a-z][a-z]\/[0-9]+\/.*$
RewriteRule \/s\/([a-z][a-z])\/([0-9]+)\/.*$ /category.php?action=something&value=$2&lang=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/s\/[0-9]+\/.*$
RewriteRule \/s\/([0-9]+)\/.*$ /category.php?action=something&value=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/n\/[a-z][a-z]\/[0-9]+\/.*$
RewriteRule \/n\/([a-z][a-z])\/([0-9]+)\/.*$ /novel.php?action=more&value=$2&lang=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^\/n\/[0-9]+\/.*$
RewriteRule \/n\/([0-9]+)\/.*$ /novel.php?action=more&value=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^\/sn\/[0-9]+\/.*$
RewriteRule \/sn\/([0-9]+)\/.*$ /novel.php?action=all&type=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^\/[a-z][a-z]\/[0-9]+\/.*$
RewriteRule \/([a-z][a-z])\/([0-9]+)\/.*$ /category.php?action=product&product=$2&lang=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^\/[0-9]+\/.*$
RewriteRule \/([0-9]+)\/.*$ /category.php?action=product&product=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^\/img\/[0-9]+\/[0-9]+\/.*$
RewriteRule \/img\/([0-9]+)\/([0-9]+)\/.*$ /img.php?value=$1-$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/[0-9]+\+[a-z][a-z]\+[0-9]+\+.*$
RewriteRule /([0-9]+)\+([a-z][a-z])\+([0-9]+)\+.*$ /category.php?action=product&product=$1&lang=$2&something=$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/[0-9]+\+[a-z][a-z]\+.*$
RewriteRule /([0-9]+)\+([a-z][a-z])\+.*$ /category.php?action=product&product=$1&lang=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/[0-9]+\+\+.*$
RewriteRule /([0-9]+)\+\+.*$ /category.php?action=product&product=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^\/img\/[0-9]+\/[0-9]+\/.*$
RewriteRule \/img\/([0-9]+)\/([0-9]+)\/.*$ /img.php?value=$1-$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/[0-9]+\+[a-z][a-z]\+[0-9]+\+.*$
RewriteRule /([0-9]+)\+([a-z][a-z])\+([0-9]+)\+.*$ /category.php?action=product&product=$1&lang=$2&something=$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/[0-9]+\+[a-z][a-z]\+.*$
RewriteRule /([0-9]+)\+([a-z][a-z])\+.*$ /category.php?action=product&product=$1&lang=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/[0-9]+\+\+.*$
RewriteRule /([0-9]+)\+\+.*$ /category.php?action=product&product=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/[0-9]+$
RewriteRule /([0-9]+)$ /category.php?action=product&product=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/s[0-9]+\+[a-z][a-z]\+.*$
RewriteRule /s([0-9]+)\+([a-z][a-z])\+.*$ /category.php?action=something&value=$1&lang=$2 [L]
</IfModule>
You can use these 2 rules in your root .htaccess:
DirectoryIndex index.php
RewriteEngine On
RewriteRule ^(?:d/)?(.+?)\.html?$ index.php?d=$1 [L,QSA,NC,R]

Apache: cannot rewrite sitemap.xml as sitemap.php

I have the following .htaccess file in the root (htdocs/johndoe) of my web document tree where index.php is found:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?lang=$1&menu1=$2&menu2=$3 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?lang=$1&menu1=$2 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?lang=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule sitemap.xml sitemap.php
Not sure what I am doing wrong, but when I access:
http://localhost/johndoe/sitemap.xml
it just loads my index.php instead of calling sitemap.php. Where am I going wrong? Thanks.
Moving the rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule sitemap.xml sitemap.php
to the top of the .htaccess file just after the RewriteEngine on directive seemed to solve my problem.

.htaccess add / support

RewriteEngine On
RewriteBase /myproject/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ $1.php [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^books/([^/]+)/$ books.php?id=$1 [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^books/([^/]+)$ books.php?id=$1 [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^books/ books.php [QSA]
Everything works when I type: localhost/name
but breaks if I type: localhost/name/
What's wrong with my .htaccess and how do I add support "/"
You don't need 2 rules and your 2nd rule has invalid regex anyway. Try this rule:
Options -MultiViews
RewriteEngine On
RewriteBase /myproject/
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^books/([^/]+)/?$ books.php?id=$1 [L,NC,QSA]
RewriteCond %{DOCUMENT_ROOT}/myproject/$1\.php -f [NC]
RewriteRule ^([^/]+)/?$ $1.php [L]

Categories