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:
<IfModule 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.
As it is in this answer - you can debug your Apache rewrites. Turn on RewriteLog in your virtual host OR server configuration:
RewriteEngine On
RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 3
Then you'll see what rule makes it to redirect 404.
Finally, I could find the solution:
Here is the code used in conjuntion with the wordpress:
<IfModule mod_rewrite.c>
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.
You can try to use own .htaccess in /backoffice/ folder with
RewriteBase /backoffice/
# all the backofice rules
Related
I'm working on a CodeIgniter application that was previously developed.
The issue that I'm getting is a page not found and I have installed on wamp.
Here is the .htaccess file that I'm currently using for the app (not the wamp one).
# Turn on URL rewriting
RewriteEngine On
# Allow these directories and files to be displayed directly:
RewriteRule ^(index\.php|css|js|fonts|images|uploads|audio) - [PT,L]
# Rewrite all other URLs to index.php/URL
# RewriteRule .* index.php?/$0 [PT,L,QSA]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
How do I go about fixing the 404 issue? Would I change the wamp .htaccess file?
Thank you,
Kevin Davis
# Turn on URL rewriting
RewriteEngine On
RewriteBase /FOLDERNAME/ #Add your foldername in place of FOLDERNAME
# Allow these directories and files to be displayed directly:
RewriteRule ^(index\.php|css|js|fonts|images|uploads|audio) - [PT,L]
# Rewrite all other URLs to index.php/URL
# RewriteRule .* index.php?/$0 [PT,L,QSA]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Try using below .htacccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Hope this can help you.
This might be something simple, but I spent days on it, without results.
My website home page URL by default is
https://rezume.am/index.php?controller=pjLoad&action=pjActionJobs
I want to see https://rezume.am/ instead.
When I added the following rule in .htaccess file:
RewriteRule ^()$ index.php?controller=pjLoad&action=pjActionJobs$1
Things worked, but filters on the left got broken.
Here is my whole .htaccess content:
#Redirection code starts
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Redirection code Ends
RewriteEngine On
RewriteRule ^(.*)-(\d+).html$ index.php?controller=pjLoad&action=pjActionView&id=$2
RewriteOptions inherit
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase //
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . //index.php [L]
#RewriteRule ^(.*)$ index.php/$1 [PT,L]
RewriteRule ^()$ index.php?controller=pjLoad&action=pjActionJobs$1
</IfModule>
Could anyone please advise a better rule to skip controllers and actions and see just domain?
I have made a php web application which uses links like :
Link
... onClick="window.location.href='/asset/image.ext'" ...
<? header("Location: /login"); ?>
etc.
As you might have noticed, almost EVERY link starts with /.
Many links are rewritten in .htaccess like this :
Options All -Indexes
RewriteEngine on
RewriteRule ^login/error_418$ assets/common/login.php?&error [L]
RewriteRule ^login$ assets/common/login.php [L]
RewriteRule ^settings/change-profile-picture$ index.php?page=settings&command=profilePicture [L]
RewriteRule ^settings/change-password/error-requirements$ index.php?page=settings&command=password&error=requirements [L]
RewriteRule ^settings/change-password/error-missmatch$ index.php?page=settings&command=password&error=missmatch [L]
RewriteRule ^settings/change-password/error-418$ index.php?page=settings&command=password&error=418 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/grades$ index.php?page=grades&course=$1 [L]
Now I need to move it on a web server where it will NOT be in the root direcotry but in a folder...
How do I now redirect all the root links to that folder ?
First place your existing rule in /folder/.htaccess like this:
Options All -Indexes
RewriteEngine on
RewriteBase /folder/
RewriteRule ^login/error_418$ assets/common/login.php?&error [L]
RewriteRule ^login$ assets/common/login.php [L]
RewriteRule ^settings/change-profile-picture$ index.php?page=settings&command=profilePicture [L]
RewriteRule ^settings/change-password/error-requirements$ index.php?page=settings&command=password&error=requirements [L]
RewriteRule ^settings/change-password/error-missmatch$ index.php?page=settings&command=password&error=missmatch [L]
RewriteRule ^settings/change-password/error-418$ index.php?page=settings&command=password&error=418 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/grades$ index.php?page=grades&course=$1 [L]
Then create a rule in root .htaccess as this:
RewriteEngine On
RewriteBase /
RewriteRule ^((?!folder/).*)$ folder/$1 [L,NC]
I have the following rules setup for my blog and they seem to work just fine.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(index\.php|(modules|css|files|fonts|ico|img|js)/)
RewriteRule ^([^/]*)/page/([^/]*)$ /framework/?p=$1&page=$2 [L]
RewriteRule ^([^/]*)/search/([^/]*)$ /framework/?p=$1&search=$2 [L]
RewriteRule ^([^/]*)/search/([^/]*)/page/([^/]*)$ /framework/?p=$1&search=$2&page=$3 [L]
So I was feeling confident and wanted to add one more rule for the just the basic page.
so I added this rule
RewriteRule ^([^/]*)$ /framework/?p=$1 [L]
so that my htaccess file now looks like this
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(index\.php|(modules|css|files|fonts|ico|img|js)/)
RewriteRule ^([^/]*)$ /framework/?p=$1 [L]
RewriteRule ^([^/]*)/page/([^/]*)$ /framework/?p=$1&page=$2 [L]
RewriteRule ^([^/]*)/search/([^/]*)$ /framework/?p=$1&search=$2 [L]
RewriteRule ^([^/]*)/search/([^/]*)/page/([^/]*)$ /framework/?p=$1&search=$2&page=$3 [L]
but for if I go to http://www.example.com/framework/blog I get a 500 Internal Server Error if I take out the line and go to http://www.example.com/framework/blog/page/2 it loads my second page without any issues.
I am not sure what I am doing wrong? Any advice would be appreciated.
You can use:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /framework/
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^([^/]+)/page/([^/]*)$ ?p=$1&page=$2 [L,QSA]
RewriteRule ^([^/]+)/search/([^/]*)/page/([^/]*)$ ?p=$1&search=$2&page=$3 [L,QSA]
RewriteRule ^([^/]+)/search/([^/]*)$ ?p=$1&search=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ ?p=$1 [L,QSA]
This is what is in my .htaccess file right now.
Now I want to eliminate the index.php in my url. How do i do this?
I have tried several possibilities from this website but either i get a 500 internal error or nothing changes at all.
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
The following code will rewrite index.php to index
RewriteEngine on
RewriteRule ^index index.php
Try if this works
Options +FollowSymLinks -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>