htaccess resulting in 500 internal error - php

The below code results in 500 internal error
RewriteBase /www/
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$profile.php?u=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$profile.php?u=$1
RewriteRule ^albums/([a-zA-Z0-9_-]+)$view_albums.php?u=$1
RewriteRule ^albums/view_photo/([a-zA-Z0-9_-]+)$view_photo.php?uid=$1

Try this code
<IfModule mod_rewrite.c>
RewriteBase /www/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?u=$1 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?u=$1 [L]
RewriteRule ^albums/([a-zA-Z0-9_-]+)$ view_albums.php?u=$1 [L]
RewriteRule ^albums/view_photo/([a-zA-Z0-9_-]+)$ view_photo.php?uid=$1 [L]
</ifModule>

Related

yii 2 not working. Object not found. What?

Installed yii2 advancedand set up .htaccess
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^/(admin)
RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L]
RewriteRule ^admin/css/(.*)$ backend/web/css/$1 [L]
RewriteRule ^admin/js/(.*)$ backend/web/js/$1 [L]
RewriteCond %{REQUEST_URI} !^/backend/web/(assets|js|css|js)/
RewriteCond %{REQUEST_URI} ^/(admin)
RewriteRule ^.*$ backend/web/index.php [L]
RewriteCond %{REQUEST_URI} ^/(assets|css|js|images)
RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]
RewriteRule ^css/(.*)$ frontend/web/css/$1 [L]
RewriteRule ^js/(.*)$ frontend/web/js/$1 [L]
RewriteRule ^images/(.*)$ frontend/web/images/$1 [L]
RewriteRule ^(.*)$ frontend/web/$1 [L]
RewriteCond %{REQUEST_URI} !^/(frontend|backend)/web/(assets|css|js)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ frontend/web/index.php
</IfModule>
follow the link - /frontend/web/
and I get an error -
In what there can be an error. I have made all as in instructions?
Obviously it get 404 Error. Because the frontend/web Rule is Rewrite using the .htaccess file.
Access your application frontend in localhost like
http://localhost/your_project_directory_name/

Clean URLs - .htaccess

Clean URLs works only on index.php but not on the other pages (explore and top).
The parameter I want to "clean" is 'genre' (for example: genre=pop). This is the website:swiftlymusic.com and is hosted on a "1&1(1and1 oneandone)" server.
.htaccess:
ErrorDocument 404 /04.html
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^log$ logs [L]
RewriteRule ^([a-zA-Z0-9]+)$ ?genre=$1 [L]
RewriteRule ^([a-zA-Z0-9]+)/$ ?genre=$1 [L]
RewriteRule ^explore/([a-zA-Z0-9_-]+)$ explore.php?genre=$1 [L]
RewriteRule ^top/([a-zA-Z0-9_-]+)$ top.php?genre=$1 [L]
AddDefaultCharset UTF-8
Try it like this,
Options -Multiviews
ErrorDocument 404 /04.html
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^log$ logs [L]
RewriteRule ^([\w-]+)$ ?genre=$1 [L]
RewriteRule ^([\w-]+)/$ ?genre=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#explore & top and any other can be use by this 1 rule
RewriteRule ^([\w]+)/([\w-]+)$ $1.php?genre=$2 [QSA,L]
Have you tried re-ordering so that the "explore.php" and "top.php" lines are above the general line? Also, you can use '?' instead of repeating the line twice: once with, once without the forward slash.
RewriteRule ^explore/([a-zA-Z0-9_\-]+)/?$ explore\.php?genre=$1 [L]
RewriteRule ^top/([a-zA-Z0-9_\-]+)/?$ top\.php?genre=$1 [L]
RewriteRule ^([a-zA-Z0-9]+)/?$ ?genre=$1 [L]

.htaccess Rewrite 505 Error Loop

I am trying to rewrite:
mydomain.com/category.php?id=cat
to
mydomain.com/cat
I have used the following .htaccess code but it keeps showing a 505 error:
RewriteEngine On
RewriteRule ^([^/]*)$ /category.php?id=$1 [L]
I read on another page that it is because the page keeps looping, but I can't work out how I can fix the code.
Keep your rule like this:
RewriteEngine On
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /category.php?id=$1 [L,QSA]
Try this.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(\w+)/ category.php?id=$1 [L]
</IfModule>
You need to add RewriteCond to avoice rewrite for category.php
RewriteEngine On
RewriteCond %{REQUEUST_URI} !^ /category.php/(.*)
RewriteRule ^(\w+)/ category.php?id=$1 [L]
Ok this should work:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/category.php
RewriteRule ^(.*)$ category.php?id=$1 [R=301,L]
Demo: http://ht6.valhook.com/cat

shorting URL with HTACCESS

htaccess in this page
www.mysite.it/LABS/page.php?id=value
to
www.mysite.it/LABS/value
i try this but not work
RewriteCond %{REQUEST_URI} LABS/page\.php?name=$1 [NC]
RewriteRule ^([^/]*)$ /page\.php?id=$1 [L]
Solutions?
I hope this works for you
RewriteEngine On
RewriteRule ^([^/]*)$ /LABS/page.php?id=$1 [L]
I usually use a mod_rewrite generator
Source
Try this :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /LABS/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ page.php?/$1 [QSA,L]
</IfModule>

.htaccess mod rewrite with variable

I am trying to do a simple redirect for my site but I'm having no luck getting it to work.
My .htaccess is:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(es|fr|pt|de|zh|ru|my|in|ae|bd)\.my-site\.com$
RewriteRule (.*) - [QSA,E=LANGUAGE:%1]
RewriteCond %{ENV:LANGUAGE} ^$
RewriteRule (.*) - [QSA,E=LANGUAGE:en]
RewriteRule (.*) $1?language=%{ENV:LANGUAGE} [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^profile/(.*)$ http://my-site/decorators/profile/$1
RewriteRule ^(.*)$ index.php
I want it to redirect to http://my-site/decorators/profile/whatever if the user browses to http://my-site/profile/whatever
Have your rules like this:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteBase /
RewriteRule ^(profile/.*)$ /my-site/decorators/$1 [NC,L,R=302]
RewriteCond %{HTTP_HOST} ^(es|fr|pt|de|zh|ru|my|in|ae|bd)\.my-site\.com$
RewriteRule (.*) - [QSA,E=LANGUAGE:%1]
RewriteCond %{ENV:LANGUAGE} ^$
RewriteRule (.*) - [QSA,E=LANGUAGE:en]
RewriteRule (.*) $1?language=%{ENV:LANGUAGE} [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
Add the following htaccess code
RewriteCond ^([profile]+)/(.*)$
RewriteRule ^([decorators]+)/([profile]+)/(.*)$
Remove the following code in your htaccess
RewriteRule ^profile/(.*)$ http://my-site/decorators/profile/$1

Categories