I have a site that needs jquery-ui and Bootstrap selection to work with #id for modals etc, it worked wonders but then I used htaccess to hide the queries and extensions, now it is not allowing the rest of the elements that work with ids to function cause it is treating it like a page I think.
My htaccess is as follows.
ErrorDocument 404 /404.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)/$ $1.php [NC,L]
RewriteRule ^about/([0-9a-zA-Z]+)$ about.php?q=$1 [NC,L]
RewriteRule ^petowners/([0-9a-zA-Z]+)$ pet-owners.php?q=$1 [NC,L]
RewriteRule ^veterinarians/([0-9a-zA-Z]+)$ veterinarians.php?q=$1 [NC,L]
RewriteRule ^veterinarian/([0-9a]+)$ pet-owners.php?q=veterinarians&vID=$1 [NC,L]
Related
I build a website with multiple languages, and until now I did a simple rewrite for internal pages.
RewriteRule ^([^/]+)$ /page.php?id=$1 [L]
So all my pages are like this:
website.com/about
But now I added another rule, for multiple languages
RewriteRule ^/?(en|es|ar|fr|de|ru|pt-br)/(.+?)/?$ /$2&lang=$1 [L]
The problem is, I have more pages, like the index page or profile pages, like this:
website.com/en/
website.com/en/profile.php
both of them are not working anymore because they redirect me to different pages. like
page.php?id=en
page.php?id=profile.php&lang=en
I'm pretty confused on what is the solution for this.
Note that I don't want my main language to have a prefix /he/
This is the entire htaccess
RewriteEngine On
ErrorDocument 404 /error
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([^/]+)$ /page.php?id=$1 [L]
RewriteRule ^/?(en|es|ar|fr|de|ru|pt-br)/(.+?)/?$ /$2&lang=$1 [L]
I want these
website.com/
website.com/en/
website.com/en/profile.php
website.com/about
website.com/en/about
to match these
website.com/
website.com/?lang=en
website.com/profile.php?lang=en
website.com/page.php?id=about
website.com/page.php?id=about&lang
Not sure if this is the best way to do this, but it works:
RewriteEngine On
ErrorDocument 404 /error
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(en|es|ar|fr|de|ru|pt-br)/?$ ?lang=$1 [L]
RewriteRule ^(en|es|ar|fr|de|ru|pt-br)/(.*).php /$2.php?lang=$1 [L]
RewriteRule ^(en|es|ar|fr|de|ru|pt-br)/?(.*) /page.php?id=$2&lang=$1 [L]
RewriteRule ^([^/]+)$ /page.php?id=$1 [L]
I tested it with this website
I am using gltf objects on my website with three.js. And I am using pretty links rules on my htaccess file. If I browse this url : https://yeni.elbielectric.com/gett.php my object is loading and appearing on page. But if I browse this url : https://yeni.elbielectric.com/urunler/zena/silverline/fildisi/anahtar/ object is loading but not disappearing. And I cannot see any console error. I think beacuse of htaccess rules there is a problem. Here is my htaccess content :
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^urunler/$ products.php [NC,L]
RewriteRule ^urunler/(.*)/(.*)/(.*)/(.*)/(.*)$ product-detail.php?prdname=$1&prddetail=$2&prdcolor=$3&functype=$4 [L]
RewriteRule ^products/(.*)/(.*)/(.*)/(.*)/(.*)$ product-detail.php?prdname=$1&prddetail=$2&prdcolor=$3&functype=$4 [L]
RewriteRule ^urunler/(.*)/(.*)$ product-list.php?prdname=$1 [L]
RewriteRule ^products/(.*)/(.*)$ product-list.php?prdname=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
there are some paths about my 3d objects and texture on js code. I think there is a problem about them.
for example : "../../../../../Models/ZenaVega/zena.gltf"
What is wrong?
Thanks.
With your shown samples/attempts, please try following .htaccess rules file. Please make sure to clear your browser cache before testing your URLs.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^urunler/?$ products.php [NC,L]
RewriteRule ^(?:urunler|products)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ product-detail.php?prdname=$1&prddetail=$2&prdcolor=$3&functype=$4 [NC,QSA,L]
RewriteRule ^(?:urunler|products)/([^/]*)/?$ product-list.php?prdname=$1 [NC,QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
RewriteRule ^(.*)/?$ $1.php [L]
I am currently using the below code for my .htacess file. It is supposed to re-write any http request to https as well as work for 1-3 variables (site.com/cat/subcat/ad).
That part works great, however it is also re-writing my images (i.e "/images/image.png"). How do I correct this code to prevent this from happening and allow my images to show?
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?cat=$1 [NC,L]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?cat=$1&subcat=$2 [NC,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?cat=$1&subcat=$2&ad=$3 [NC,L]
I need help with my htaccess file. I added the following to remove all .php extensions which is working fine.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
However I have a directory /users which I want to rewrite the URL strings. The current URL is like this:
aero.site/maki/users/index.php?t=mf5cc
I want the URL to look like
aero.site/maki/mf5cc
I used the following rewrite rule but it's giving me Object not found error:
RewriteRule ^([^/.]+)$ users/index.php?t=$1 [L]
My complete htaccess content is
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^([^/.]+)$ users/index.php?t=$1 [L]
Kindly help me with the correct rewrite rule for the last line to turn aero.site/maki/users/index.php?t=mf5cc into aero.site/maki/mf5cc
FYI: my htaccess file is in aero.site/maki directory
I finally got it to work. Thanks to #misorude. Here's my updated .htaccess content:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^([^/.]+)$ users/index?t=$1 [L]
I have searched for this but nobody have the same issue..
Now I need an code to transform the ugly url (thats what i have) to the nice url:
Ugly url: domain.com/aanmelden?referral=admin
Nice url: domain.com/aanmelden/admin
Ik have tried soo many codes, but no one did work for me. ):
suggestions?
Thnx!
(My current htaccess: )
ErrorDocument 401 /errordocs/401.php
ErrorDocument 403 /errordocs/403.php
ErrorDocument 404 /errordocs/404.php
ErrorDocument 500 /errordocs/500.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^domain.nl$ [NC]
RewriteRule ^(.*)$ http://domain.nl/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s.+\.php\sHTTP/.+
RewriteRule ^(.+)\.php $1 [R=301,L]
Where and what i need to place?
EDIT:
To be clear:
If the user goes to the Nice Url, they wil stay on the nice one.
If the user goes to the Ugly Url, they wil redirect to the Nice url.
This is a trivial rewrite:
If admin can be any lowercase string, use the pattern ([a-z]+)$ to capture one or more lowercase letters after the / and before the end of the request URI.
RewriteEngine On
RewriteRule ^aanmelden/([a-z]+)$ aanmelden?referral=$1 [L]
If admin is really only admin, you can hard-code it as
RewriteEngine On
RewriteRule ^aanmelden/admin aanmelden?referral=admin [L]
Update
In context of your existing rewrites just posted, you'll need to add this rule before the rule that adds .php since that would also match this pattern.
# Do this before the rule that adds .php
# Also added condition so this doesn't apply to real files...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^aanmelden/([a-z]+)$ aanmelden?referral=$1 [L]
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Update 2
If you want the end user to get the ugly URL and rewrite it to the nice one, use:
RewriteCond %{REQUEST_QUERYSTRING} referral=([a-z]+)
RewriteRule ^aanmelden aanmelden/%1 [L]