vitoold2078
vitoold2078

Reputation: 436

.htaccess Rewrite 403 Forbidden

I have a .htaccess rule for get content from the file partnerzy.php when user types:

https://example.com/partnerzy and https://example.com/partnerzy/

at address field. My .htaccess contains:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_URI} /partnerzy
RewriteRule partnerzy.php [NC]
RewriteCond %{REQUEST_URI} /partnerzy/
RewriteRule ^(.*) partnerzy.php [NC]

The rule works on different service, but for my site I get

403 Forbidden
You don't have permission to access this document.

Why it doesn't works ?

Upvotes: 0

Views: 3820

Answers (2)

vitoold2078
vitoold2078

Reputation: 436

The server contains the same folder name like rewrite result /partnerzy/. Apache doesn't know what to load: partnerzy/ content from partnerzy.php (rewrite rule) or partnerzy/index.(*) and says: 403 Forbidden

There are two ways to solve issue:

  • make partnerzy/.htaccess with Options +DirList rule,

  • change dir name partnerzy to another

Then there is no colision with 403 Forbidden

Upvotes: 0

anubhava
anubhava

Reputation: 785108

You have a syntax issue in your first RewriteRule.

Replace all of your code with this:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(partnerzy)/?$ $1.php [L,NC]

Upvotes: 1

Related Questions