Having trouble with godaddy htaccess file - apache

RewriteEngine On
RewriteBase /
RewriteRule ^/?$ /1 [L]
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^sayfa-([0-9a-zA-Z-_]+) menu-detay.php?sef=$1 [L,QSA]
RewriteRule ^kategori-([0-9a-zA-Z-_]+) kategoriler.php?sef=$1 [L,QSA]
RewriteRule ^urun-([0-9a-zA-Z-_]+)-([0-9]+)$ urun-detay.php?sef=$1&urun_id=$2 [L,QSA]
RewriteRule ^urun-([0-9a-zA-Z-_]+) urun-detay.php?sef=$1 [L,QSA]
RewriteRule ^bize-ulasin$ iletisim.php [NC,L]
RewriteRule ^sitemap.xml$ sitemap.php [NC,L]
</IfModule>
This is my htaccess file and seo links are not working. Im using LINUX hosting and couldnt find anything helpfull.
When i click my seo url on my index like "website.com/product-33v-new-generation" it redirect me to homepage.
RewriteRule ^urun-([0-9a-zA-Z-_]+)-([0-9]+)$ urun-detay.php?sef=$1&urun_id=$2 [L,QSA]
This is my seo url link for products
RewriteRule ^kategori-([0-9a-zA-Z-_]+) kategoriler.php?sef=$1 [L,QSA]
And this one is for categories.
But non of them are working for somehow. I have another linux hosting but they are working just fine.
Any help appericiated.

With your shown samples, please try following htaccess Rules. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine On
RewriteBase /
RewriteRule ^/?$ index.php [L]
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
##RewriteRule ^(.*)/?$ index.php [L]
RewriteRule ^ index.php [L]
RewriteRule ^sayfa-([0-9a-zA-Z-_]+) menu-detay.php?sef=$1 [NC,L,QSA]
RewriteRule ^kategori-([0-9a-zA-Z-_]+) kategoriler.php?sef=$1 [NC,L,QSA]
RewriteRule ^urun-([0-9a-zA-Z-_]+)-([0-9]+)$ urun-detay.php?sef=$1&urun_id=$2 [NC,L,QSA]
RewriteRule ^urun-([0-9a-zA-Z-_]+) urun-detay.php?sef=$1 [L,QSA]
RewriteRule ^bize-ulasin/?$ iletisim.php [NC,L]
RewriteRule ^sitemap\.xml/?$ sitemap.php [NC,L]
</IfModule>
Few fixes in OP's tried htaccess Rules file:
You need NOT to use multiple <IfModule mod_rewrite.c> sections as per your shown attempts.
Need not to use multiple RewriteBase, you could mention it in starting of Rules.
Also fixed few Rules flags and regex in few of the other rules here.

Related

How to fix mod_rewrite problem with static to dynamic content

I would appreciate if someone can help with this mod rewrite issue. For years I had this in my htaccess, apache include files and it worked just fine.
RewriteRule ^/article/([0-9]*).html$ /article/article.php?id=$1 [NC,L]
But recently it stopped working. Browser shows "No input file specified." and access log shows 404 response code the requests that had to be fulfilled by the condition above.
RewriteEngine is on. This is what my htaccess mod_rewrite rules at the moment
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^/article/([0-9]*).html$ /article/article.php?id=$1 [NC,L]
RewriteRule ^/relationships/([0-9]*).html$ /article/article.php?id=$1 [NC,L]
</IfModule>
With your shown samples/attempts, could you please try following htaccess Rules. Please make sure to place your htaccess rules file in root and clear your browser cache before testing your URLs.
<IfModule mod_rewrite.c>
Options -MultiViews -Indexes
RewriteEngine On
RewriteBase /
##Rules for non-existing pages.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
##Rules for articile and relationship uris here.
RewriteRule ^(?:article|relationships)/([0-9]*)\.html/?$ article/article.php?id=$1 [NC,L]
##Rules for 404 handling.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) 404error.php [L,NC]
</IfModule>

.htaccess rewrite rule not working

I've been looking few different tutorials about it like
https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
and I thought it would be easy to do my own rewrite rule but I don't know why it's not working.
this is what I have in my htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp2/
RewriteRule ^lol portafolio [NC,L] # Change feed URL
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp2/index.php [L]
</IfModule>
# END WordPress
and when I write wwww.domain.com/wp2/lol it's not redirecting me to wwww.domain.com/wp2/portafolio which this code:
RewriteRule ^lol portafolio [NC,L] # Change feed URL
should do.. I guess it's not correct. Why it's not doing the rewriting correctly? I need to rewrite a bunch of URLS.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Try this code. it will help you
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

htaccess rewrite doesn't work on 2nd level rewrite

I have the following lines in my .htaccess
Options +FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ seo.php?p=$1 [L]
RewriteRule ^seo/site:(.*)$ seo.php?p=seo&domain=/$1&status=seo [QSA]
RewriteRule ^seo/(.*)$ seo.php?p=seo&domain=/$1&status=seo [L]
RewriteRule ^admin/page:(.*)$ seo.php?p=admin&page=/$1 [L]
RewriteRule ^webagent/page:(.*)$ seo.php?p=webagent&page=/$1 [L]
RewriteRule ^setlang:(.*)$ seo.php?setlang=/$1 [L]
RewriteRule ^(.*)/setlang:(.*)$ seo.php?p=/$1&setlang=/$2 [L]
</IfModule>
The problem is that only first Rule works normal. it takes pages from currently defined folder in php
When i try to open
seo/domain.com
it doesn't work but when i open
seo.php?p=seo&domain=domain.com&status=seo
works very well.
Where i go wrong with this .htaccess file.
Have your rules like this:
Options +FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^seo/site:(.*)$ seo.php?p=seo&domain=/$1&status=seo [L,QSA]
RewriteRule ^seo/(.*)$ seo.php?p=seo&domain=/$1&status=seo [L,QSA]
RewriteRule ^admin/page:(.*)$ seo.php?p=admin&page=/$1 [L,QSA]
RewriteRule ^webagent/page:(.*)$ seo.php?p=webagent&page=/$1 [L,QSA]
RewriteRule ^setlang:(.*)$ seo.php?setlang=/$1 [L,QSA]
RewriteRule ^(.*)/setlang:(.*)$ seo.php?p=/$1&setlang=/$2 [L,QSA]
RewriteRule ^(.*)$ seo.php?p=$1 [L,QSA]
</IfModule>

Apache rewrite for SEFs

How to have requests to be handled by index.php
For instance
If I type SEFs in the browser
http://localhost/friends
http://localhost/me
Rewrites to
http://localhost/index.php/friends
http://localhost/index.php/me
So I could access friends or me from $_REQUEST['PATH_lNFO']
I've mod rewrite on and allow all directive set for the root directory in apache.
Need a .htaccess file,
look in this article http://www.sitepoint.com/apache-mod_rewrite-examples/ for this RewriteRule ^/?([a-zA-Z_]+)/([a-zA-Z_]+)/([a-zA-Z_]+)$ display.php?country=$1&state=$2&city=$3 [L]
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /rtest
RewriteCond %{HTTP_HOST} ^mathpdq\.com
RewriteRule ^(.*)$ http://www.mathpdq.com/rtest/$1 [R=permanent,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
http://mathpdq.com/rtest/fred
RewriteRule ^friends$ index.php/friends [L]
RewriteRule ^me$ index.php/me [L]
that's all.
$_REQUEST['PATH_INFO'] will be set to "/friends" or "/me".
(Depending on your server configuration ORIG_PATH_INFO might have to be used instead of PATH_INFO)

Apache mod rewrite .htaccess problem

My site is a php based site, but I've added wordpress in a /blog/ folder. The .htaccess file below should allow the /blog/ folder to be accessed, but I get a 404 error saying that blog.php doesn't exist.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !\.(gif|jpg|png)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/(.*)/$ /$1_$2.php [L]
RewriteRule ^(.*)/$ /$1.php [L]
</IfModule>
Anybody able to help at all?
The last RewriteRule is redirecting your request to /blog/ to index.php, you should add a RewriteCond to check if the request is on the blog folder.
RewriteCond %{REQUEST_URI} !^/blog/.*
I managed this using the code below, for some reason the conditionals that were suggested don't work (I HATE .htaccess)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(blog) - [L]
RewriteCond %{SCRIPT_FILENAME} !\.(gif|jpg|png)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/(.*)/$ /$1_$2.php [L]
RewriteRule ^(.*)/$ /$1.php [L]
</IfModule>
Adding
RewriteRule ^(blog) - [L]
to public_html/.htaccess after
RewriteEngine On
worked for me as well on a fresh Wordpress installation with Fantastico on a Hostgator account, with a blog.example.com subdomain.