I have tried the following in htaccess but does not seem to work,
Options +FollowSymLinks +Indexes +MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ $1.php?bid=$2&page=$3 [L]
By doing this,
http://www.turkish-property-world.com/antalya_apartment.php?bid=4&page=1
should be
http://www.turkish-property-world.com/antalya_apartment/4/1
Your rule is correct but real problem is your use of MultiViews. Take it out using:
Options +FollowSymLinks +Indexes -MultiViews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ $1.php?bid=$2&page=$3 [L,QSA]
Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)/(.*)/$ $1.php?bid=$2&page=$3 [L,QSA]
RewriteRule ^(.*)/(.*)/(.*)$ $1.php?bid=$2&page=$3 [L,QSA]
Related
I'm needing to merge both of these inside my .htaccess folder. If the top one runs, WordPress works properly but my forum does not. If the bottom one runs it's reversed. I've done some research and I found it's because I have multiple RewriteBases in the code. I'm needing some help getting them merged together though. Thank you.
<IfModule mod_setenvif.c>
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
</IfModule>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /forum/api/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /forum/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /forum/404error.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /forum/index.php [L]
</IfModule>
I think I figured it out. This is at least working for me.
<IfModule mod_setenvif.c>
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
</IfModule>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^forum/api/.* index.php [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^forum/\.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /forum/404error.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^forum/. /forum/index.php [L]
</IfModule>
I've tried searching multiple previous threads on setting up url rewrite correctly for a Silex application on XAMPP, but still can't figure this issue out. Here is what I am trying to accomplish.
I am using XAMPP and here is the structure of my htdocs folder:
- xampp
- htdocs
- app1
- app2
- app3 <silex application>
.htaccess file (outside of web folder)
- web
index.php file
I can currently do http://localhost:50000/msk/web/cte. My question is how do I get rid of "web" from this (i.e. http://localhost:50000/msk/cte)
I feel like I'm missing something minor, but I can't figure it out.
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /msk/web/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
LoadModule rewrite_module modules/mod_rewrite.so is un-commented in my config.
I am not using virtual hosts either.
Thanks
Try this one
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
You can try :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /msk/web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^cte/url-word$ cte/redirect-page [L]
</IfModule>
use the following .htaccess in /msk directory:
Options +FollowSymLinks
IndexIgnore */*
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(web)
# ------- browser looks for them on base url -------- ex: /images/logo.png
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
RewriteRule (.*) /web/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php
</IfModule>
and use this .htaccess in your /msk/web directory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>
I need to correct the below re-writes rule below so that any url called will get directed to / or index.html but if the url is for the web service (/ws/controller/function) then i want it to direct to /ws/index.php
For my angular 2 in the html i have
<base href="/">
And the url is format xxx/yyy/ not #/xx/yy
my .htaccess is
<ifModule mod_rewrite.c>
RewriteEngine on
Options FollowSymLinks
RewriteBase /ws/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /ws/index.php?url=$1 [L,QSA]
</ifModule>
<ifModule mod_rewrite.c>
RewriteEngine On
Options FollowSymLinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /#/$1 [L]
</ifModule>
It works fine as it is but when the user reloads the page on any other than the root the app falls over.
Thanks
I think this would help:
<ifModule mod_rewrite.c>
RewriteEngine On
Options FollowSymLinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/ws/
RewriteRule ^(.*)$ index.html [L,QSA]
RewriteRule ^(ws/.*)$ ws/index.php?request=$1 [L,QSA]
</ifModule>
I have this code in my htaccess file:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-/_]+)/?$ http://subdomain.example.com/index.php?id=$1 [L,QSA]
but everytime i go to something like http://subdomain.example.com/test/test
it should resolve to:
http://subdomain.example.com/index.php?id=test/test
which it does, but its changing my URL to be the above and its not keeping the original URL
Remove http:// from your target URL:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} =subdomain.example.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?id=$1 [L,QSA]
I have also corrected your regex in RewriteRule.
I'm trying to make clean urls with php and im getting some errors. Hope someone can help.
My .htaccess is as follows:
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
# this is the initialization
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /
# these are the rewrite conditions
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# and finally, the rewrite rules
RewriteRule ^([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1 [L,QSA]
RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1&var2=$2 [L,QSA]
RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1&var2=$2&var3=$3 [L,QSA]
Actually I'm trying to make clean urls in the subfolder price/.
When I enter: mydomain.com/price/param1 it works perfect and it actually redirects me to
mydomain.com/price/index.php?var1=param1
But when I try to go forward with more variables is when I get the problem. When I try to access mydomain.com/price/param1/param2 I'm not redirected and a 404 error appears.
Any idea? Thanks in advance.
Try:
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
<IfModule mod_rewrite.c>
# This is the initialization
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /
# /price/var1/var2/var3
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^price/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1&var2=$2&var3=$3 [L,QSA]
# /price/var1/var2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^price/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1&var2=$2 [L,QSA]
# /price/var1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^price/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1 [L,QSA]
</IfModule>