Jump to content

Not Working


hackalive

Recommended Posts

Hi guys,

 

I have this htaccess code:

 

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/.]+)/?$ /redirects/$1.php [N]
RewriteRule ^([^/.]+)/?$ /$1.php [L]
RewriteRule ^([^/.]+)/([^/.]+)/?$ /$1/$2.php [L]

 

It works a treat anything like mydomain.com/xyz that has a file in the folder mydomain.com/redirects/ calls the file in the redirects folder and lets me PHP 301 everyone.

 

I now want it to work for mydomain.com/redirects/anyotherfoler/ so I tried:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/.]+)/?$ /redirects/$1.php [N]
RewriteRule ^([^/.]+)/([^/.]+)/?$ /redirects/$1/$2.php [N]
RewriteRule ^([^/.]+)/?$ /$1.php [L]
RewriteRule ^([^/.]+)/([^/.]+)/?$ /$1/$2.php [L]

 

Which does redirect me, but RewriteRule ^([^/.]+)/([^/.]+)/?$ /redirects/$1/$2.php [N] still "powers on" and is called on the new url and I get an error of:

 

Not Found

 

The requested URL /redirects/folder/file.php was not found on this server.

Apache/2.2.22 (Win32) DAV/2 PHP/5.4.0 Server at 10.0.0.1 Port 80

 

 

So any ideas why this is happening?

 

I tried:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/.]+)/?$ /redirects/$1.php [N]
RewriteCond /redirects/%{REQUEST_FILENAME} !-f
RewriteCond /redirects/%{REQUEST_FILENAME} !-d
RewriteCond /redirects/%{REQUEST_FILENAME} !-l
RewriteRule ^([^/.]+)/([^/.]+)/?$ /redirects/$1/$2.php [N]
RewriteRule ^([^/.]+)/?$ /$1.php [L]
RewriteRule ^([^/.]+)/([^/.]+)/?$ /$1/$2.php [L]

 

But it didn't help.

 

So any ideas?

 

Cheers

 

PS

 

This does not work either - same error:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/.]+)/?$ /redirects/$1.php [N]
RewriteCond {DOCUMENT_ROOT}/redirects/%{REQUEST_FILENAME} !-f
RewriteCond {DOCUMENT_ROOT}/redirects/%{REQUEST_FILENAME} !-d
RewriteCond {DOCUMENT_ROOT}/redirects/%{REQUEST_FILENAME}" !-l
RewriteRule ^([^/.]+)/([^/.]+)/?$ /redirects/$1/$2.php [N]
RewriteRule ^([^/.]+)/?$ /$1.php [L]
RewriteRule ^([^/.]+)/([^/.]+)/?$ /$1/$2.php [L]

Link to comment
https://forums.phpfreaks.com/topic/273725-not-working/
Share on other sites

I think this is the solution

 

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php  !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)/?$ /redirects/$1.php [N]
RewriteCond %{DOCUMENT_ROOT}/redirects/%{REQUEST_FILENAME}.php  !-f
RewriteCond %{DOCUMENT_ROOT}/redirects/%{REQUEST_FILENAME} !-d
RewriteRule ^/redirects/([^/.]+)/([^/.]+)/?$ /redirects/$1/$2.php [N]
RewriteRule ^([^/.]+)/?$ /$1.php [L]
RewriteRule ^([^/.]+)/([^/.]+)/?$ /$1/$2.php [L]

 

Any comments on it?

Link to comment
https://forums.phpfreaks.com/topic/273725-not-working/#findComment-1408701
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.