.htaccess rewriterule is not working in server - .htaccess

Here is my .htaccess code,the below code is perfectly working in localhost.in localhost it leads me to a not found page (404).
my directory structure is www.mysite.com/shoppe/
RewriteEngine On
RewriteCond %{REQUEST_URI} main
RewriteRule ^main/([A-Za-z0-9-]+)/?$ /shoppe/main.php?main_id=$1 [L]
RewriteCond %{REQUEST_URI} sub
RewriteRule ^sub/([A-Za-z0-9-]+)/?$ /shoppe/sub.php?category=$1 [L]
RewriteCond %{REQUEST_URI} product
RewriteRule ^product/([A-Za-z0-9-]+)/?$ /shoppe/product.php?pro_ids=$1 [L]

Related

Code in my .htaccess causing too many redirects

I have added to my .htaccess the following code
RewriteRule ^(.*[^/])$ /$1/ [R=302,L]
with the rest of code in .htaccess it 's causing too many redirects
RewriteEngine On
RewriteCond %{REQUEST_URI} /slovnik-pojmu.*/.*/
RewriteRule (.*)-([^\/]+)/(.*)/ /index.php?page=$1&mid=$2&word=$3 [L,QSA]
RewriteCond %{REQUEST_URI} ^/.*poslat-odkaz.*/$
RewriteRule .* - [F,L]
RewriteRule ^(.*[^/])$ /$1/ [R=302,L]
Do you have any idea what is causing the redirects?
I'm testing this address: www.energy21.cz/kontakt-190

in htaccess RewriteEngine not work on specific directory

I using yii2 and I have a problem in .htaccess as below:
I can't access to js directory to use including files in my code.
ex: yii2/sepadmin/js/jquery.min.js net::ERR_ABORTED 404 (Not Found)
Here is my .htaccess:
RewriteEngine On
# deal with sepadmin first
RewriteCond %{REQUEST_URI} ^/yii2/(sepadmin)
RewriteRule ^sepadmin/assets/(.*)$ backend/web/assets/$1 [L]
RewriteRule ^sepadmin/css/(.*)$ backend/web/css/$1 [L] #Accessible
RewriteRule ^sepadmin/js/(.*)$ backend/web/js/$1 [L] # Not Accessible
RewriteCond %{REQUEST_URI} !^/yii2/backend/web/(assets|css)/
RewriteCond %{REQUEST_URI} ^/yii2/(sepadmin)
RewriteRule ^.*$ backend/web/index.php [L]
As I mentioned the line, I can access css directory but I can't access js directory
I found the solution, I had to use directory name in REQUEST_URI as bellow.
RewriteEngine On
# deal with sepadmin first
RewriteCond %{REQUEST_URI} ^/yii2/(sepadmin)
RewriteRule ^sepadmin/assets/(.*)$ backend/web/assets/$1 [L]
RewriteRule ^sepadmin/css/(.*)$ backend/web/css/$1 [L]
RewriteRule ^sepadmin/js/(.*)$ backend/web/js/$1 [L]
RewriteRule ^sepadmin/files/(.*)$ backend/web/files/$1 [L]
RewriteCond %{REQUEST_URI} !^/yii2/backend/web/(assets|css|js|files)/
RewriteCond %{REQUEST_URI} ^/yii2/(sepadmin)
RewriteRule ^.*$ backend/web/index.php [L]

Codeigniter Error 500 in subdomain

So, I recently installed codeigniter in a subdomain and I'm getting 500 error when I try to access it. Script should run normal, I had it on several other domains and my guess it's htaccess on the main domain folder (public_html).
Here's the .htaccess from the "root" folder
#OLD
RewriteCond %{HTTP_HOST} ^domain.tv$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.tv$
RewriteCond %{HTTP_HOST} !^db\.domain\.com$ [NC]
RewriteRule ^/?$ http://domain.com/blog/topics/vidcast/ [R=301,L]
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^blog/index.php/archives/category/podcast/feed$ http://feeds.feedburner.com/domainPodcast [R=301,L]
#RewriteCond %{HTTP_HOST} !^(www|ftp|webmail)\.milaraki\.com
#RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com
#RewriteRule (.*) http://domain.com/blog/wp-content/uploads/%1/$1 [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
And here's the .htaccess in the subdomain (named: db.domain.com)
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([a-z0-9_-]+)\.html$ index.php/page/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|asset|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Now, whenever I try to access "http://db.domain.com", it redirects me to "http://db.domain.com/blog/". If I try to access by subfolder
like "http://domain.com/db" it give's me an 500Error.
We also get these spam of lines in apache/error_log:
warn] (103)Software caused connection abort: mod_fcgid: ap_pass_brigade failed in handle_request function
Also, let me tell you it's in a VPS and the "root" .htaccess file it's not made by me, but from the client, all I have done, it's to add an extra line in his .htaccess file to "stop" the redirect but it's not working at all.
That's the line I added (already in the code i posted)
RewriteCond %{HTTP_HOST} !^db.domain.com$ [NC]
It still gives the error even if I remove it or leave it there.
Oh and, in the "root" folder, he installed WordPress.
Hope I was clear enough, feel free to ask me other questions.
So, I ended up removing the lines bellow from the .htaccess file inside the "root" folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
Restarted Apache (no idea why this is necessary) and the new settings fixed everything...

Two .htaccess files doesn't work together

I have two htaccess files and one of them located in root directory and other one in gifts/ directory.
Root .htaccess contains:
RewriteEngine on
RewriteCond %{REQUEST_URI} /gifts/
RewriteRule gifts/([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)$ gifts/catalog.php?catalog=$1 [NC,L]
RewriteCond %{REQUEST_URI} /gifts/
RewriteRule gifts/([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)/([0-9]+)$ gifts/catalog.php?catalog=$1&page=$2 [NC,L]
Gifts/ .htaccess contains:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^gifts.example.com$ [NC]
RewriteRule ^([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)$ /catalog.php?catalog=$1 [NC,L]
RewriteCond %{HTTP_HOST} ^gifts.example.com$ [NC]
RewriteRule ^([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)/([0-9]+)$ /catalog.php?catalog=$1&page=$2 [NC,L]
When I go to the following URL:
http://gifts.example.com/jeans
It works, but the following URL doesn't work
http://example.com/gifts/jeans
Not Found error occurs
Try gifts/.htaccess as:
RewriteEngine on
RewriteBase /gifts/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)/?$ catalog.php?catalog=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)/([0-9]+)/?$ catalog.php?catalog=$1&page=$2 [QSA,L]

dot is not working in htaccess as defined in htaccess rules

I don't have much knowledge in .htaccess and I am struggling with regex concept in .htaccess.
I want same url concept as on facebook for user profile but dash(-), underscore(_), dot(.) this I want in url also currently my url rule is as follow:
RewriteRule ^([a-z,\_,A-Z,\_,\-,0-9.][!pagenotfound|home|abuse/*|user/*|start/*|login/*|account/*|message/*|find/*|cms/*|accountactivation/*|register/*]*)/?$ memberspersonalinfo.php?members=$1 [QSA]
This pattern have some error
but when in my browser domain.com/username is comming it's working fine but when url will be domain.com/test-test or test_test or test.test it redirects to `PAGE NOT FOUND PAGE
and in my .htaccess rule defined to follow that rule like abuse/* have dynamic id wherever I have used star (*) they are referencing dynamic value. When I will do rule like
RewriteRule ^([a-z,\_,A-Z,\_,\-,0-9.]*)/?$ memberspersonalinfo.php?members=$1 [QSA]
It's working fine but when I moveto home page then it calls memberspersonalinfo.php page it self.
I am trying to explain my Question again with htaccess script
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
DirectoryIndex index.html index.php
ErrorDocument 404 /pagenotfound
ErrorDocument 403 /pagenotfound
ErrorDocument 401 /slapme/pagenotfound
ErrorDocument 500 /pagenotfound
#index
RewriteRule ^index.html$ index.php [L]
RewriteRule ^index$ index.php [L]
RewriteRule ^home$ index.php [L]
#nopage
RewriteRule ^pagenotfound$ nopage.php [L]
#Regitration
RewriteRule ^register/createaccount$ userregistration.php [L]
#Regitration Confirmation
RewriteRule ^register/accountconfirmation$ registrationconfirm.php [L]
#Activation Regitration
RewriteRule ^accountactivation/([a-z,\_,A-Z,\_,\-,0-9]*)/([a-z,\_,A-Z,=,\_,\-,0-9]*)$ registrationactivation.php?UsercontactID=$1&AccountId=$2 [L]
#after login
RewriteRule ^user/main$ after_login.php [L]
#Payment Detail
RewriteRule ^user/myaccount$ useraccount.php [L]
#Logout
RewriteRule ^user/logout$ logoutuser.php [L]
#creategroup
RewriteRule ^start/creategroup$ http://domain.com/start/creategroup [L,R=301]
#Forgot Password
RewriteRule ^user/forgotpassword$ http://domain.com/user/forgotpassword [L,R=301]
#Login
RewriteRule ^login/userlogin$ http://domain.com/login/userlogin [L,R=301]
#Remove account
RewriteRule ^account/remove$ removeuseraccount.php [L]
#Send an email page
RewriteRule ^message/?$ contacttouser.php [L,QSA]
#Report any site user page
RewriteRule ^abuse/([0-9]*)/$ reportsiteuser.php?reportUserID=$1 [L,QSA]
#CMS FIND FRIENDS PAGE
RewriteRule ^find/friend$ http://domain.com/find/friend [L,R=301]
#CMS TERMS OF USE PAGE
RewriteRule ^cms/howitworks$ howitworks.php [L]
#CMS CREATE OWN SLAP PAGE
RewriteRule ^cms/createownslap$ createownslap.php [L]
#CMS BRAND OR PRODUCT PAGE
RewriteRule ^cms/brandorproduct$ brandorproduct.php [L]
#CMS APPS AND FEATURES PAGE
RewriteRule ^cms/appsandfeatures$ appsandfeatures.php [L]
this my full htaccess code everthing is working fine all rules are working but when i add
#group personal profile page page
RewriteCond %{REQUEST_URI} !/abuse(.*)
RewriteCond %{REQUEST_URI} !/user(.*)
RewriteCond %{REQUEST_URI} !/start(.*)
RewriteCond %{REQUEST_URI} !/login(.*)
RewriteCond %{REQUEST_URI} !/account(.*)
RewriteCond %{REQUEST_URI} !/message(.*)
RewriteCond %{REQUEST_URI} !/find(.*)
RewriteCond %{REQUEST_URI} !/cms(.*)
RewriteCond %{REQUEST_URI} !/accountactivation(.*)
RewriteCond %{REQUEST_URI} !/register(.*)
RewriteCond %{REQUEST_URI} !/social(.*)
RewriteCond %{REQUEST_URI} !/images(.*)
RewriteCond %{REQUEST_URI} !/css(.*)
RewriteCond %{REQUEST_URI} !/js(.*)
RewriteCond %{REQUEST_URI} !/userimages(.*)
RewriteRule ^([a-z,\_,A-Z,\_,\-,0-9.]+)/?$ memberspersonalinfo.php?members=$1 [QSA,L]
it always loads memberspersonalinfo.php

Resources