0

I have 1 subfolder located at my root folder: /root/task6/index.php

And I need to change urls www.andriussulcas.prinusprojects.lt/task6/index.php?p=naujienos&title=title to www.andriussulcas.prinusprojects.lt/task6/naujienos/title

I've been trying to do this for some time now and all my efforts weren't successful. While searching for answer, I started thinking that maybe my mod_rewrite wasn't activated. But later on I found how to redirect my web site root to subdirectory, where all my files are. So mod_rewrite works.

I found some similar answers here, on stackoverflow, like how to "rewrite rule" for a sub-sub-directory? .htaccess/php but for some reason it doens't work for me.

Here's my .htaccess file:

Options +FollowSymLinks
RewriteEngine On 

RewriteCond %{HTTP_HOST} ^(www.)?andriussulcas.akademija.prinusprojects.lt$
RewriteCond %{REQUEST_URI} !^/task6/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /task6/$1
RewriteCond %{HTTP_HOST} ^(www.)?andriussulcas.akademija.prinusprojects.lt$ 
RewriteRule ^(/)?$ task6/index.php?p=naujienos [L]

RewriteRule ^naujienos/([A-Za-z0-9-]+)?$ index.php?p=naujienos&title=$1 [L]

.htaccess file is located at my root directory, and there are no other .htaccess files at subdirectories.

All help is much appreciated.

Community
  • 1
  • 1
CrazySabbath
  • 1,274
  • 3
  • 11
  • 33

1 Answers1

0

Try replacing your last rule with this:

RewriteCond %{HTTP_HOST} ^(www.)?andriussulcas.akademija.prinusprojects.lt$ 
RewriteRule ^naujienos/([A-Za-z0-9-]+)$ /task6/index.php?p=naujienos&title=$1 [L]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220