Saturday 23 December 2017

php - Friendly URL within a directory

itemprop="text">


I have a Wordpress
installation in a domain and within a directory, I have a site developed in PHP+MySQL
completely independent of the wordpress. It works alone. This site is a backoffice, so
it's installed under the /backoffice/
directory.



One of the directories of the
backoffice I have another directory I want it works with friendly
URL's.



In my .htaccess I have the following
rules:



            mod_rewrite.c>
RewriteEngine On
RewriteBase
/


RewriteRule ^backoffice/edit_user/([^/\.]+)/?$
/backoffice/edit_user/index.php?o=$1
[L,NC,QSA]


RewriteRule ^index\.php$ -
[L]
RewriteCond %{REQUEST_URI} !=/server-status
RewriteCond
%{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}
!-d
RewriteRule . /index.php [L]
RewriteRule ^login/?$ wp-login.php
[QSA,L]

RewriteRule ^postpass/?$ wp-login.php?action=postpass
[QSA,L]
RewriteRule ^logout/?$ wp-login.php?action=logout
[QSA,L]
RewriteRule ^lostpassword/?$ wp-login.php?action=lostpassword
[QSA,L]
RewriteRule ^retrievepassword/?$ wp-login.php?action=retrievepassword
[QSA,L]
RewriteRule ^resetpass/?$ wp-login.php?action=resetpass
[QSA,L]
RewriteRule ^rp/?$ wp-login.php?action=rp
[QSA,L]
RewriteRule ^register/?$ wp-login.php?action=register
[QSA,L]





When
invoked a url like this one: mydomain.com/backoffice/edit_user/joseantonio the 404 page
come up.



What's
wrong?



Thanks in advance.



Answer




Finally, I could find the
solution:



Here is the code used in conjuntion
with the wordpress:






RewriteEngine On
RewriteBase
/

RewriteRule ^index\.php$ - [L]

**RewriteRule
^backoffice/edit_user/([^/\.]+)/?$ /backoffice/edit_user/index.php?o=$1
[L,NC,QSA]**

RewriteCond %{REQUEST_URI}
!=/server-status

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteRule ^login/?$ wp-login.php [QSA,L]
RewriteRule ^postpass/?$
wp-login.php?action=postpass [QSA,L]
RewriteRule ^logout/?$
wp-login.php?action=logout [QSA,L]
RewriteRule ^lostpassword/?$
wp-login.php?action=lostpassword [QSA,L]
RewriteRule ^retrievepassword/?$
wp-login.php?action=retrievepassword [QSA,L]
RewriteRule ^resetpass/?$
wp-login.php?action=resetpass [QSA,L]
RewriteRule ^rp/?$
wp-login.php?action=rp [QSA,L]

RewriteRule ^register/?$
wp-login.php?action=register
[QSA,L]


As you can
see, I changed the position of my rule after the index.php rule, works fine, in any
other position, it will not work.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...