htaccess not rules with index and another page with param - apache

I have a problem to configure a simple htaccess with two pages to rewrite: the index and the page.php?param=valueparam
The problem is that one of these rules its correct the another don't work.
These is that I need:
index.php -> mydomain.com/
page.php?param=valueparam -> mydomain.com/valueparam
I tried several options but anything rules that I want:
Options +FollowSymLinks
Options -Indexes
php_value default_charset None
AddDefaultCharset utf-8
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9a-z_-]*)$ page.php?param=$1 [NC,L]

Based on your shown samples only, could you please try following htaccess rules file, please make sure you clear your browser cache before testing your URLs.
RewriteEngine ON
##For index.php -> mydomain.com as per OP's first condition.
RewriteRule ^/?$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(valueparam)/?$ page.php?param=$1 [NC,L]

Related

Can we write .htaccess for two different dynamic pages like product.php & blog.php in php mysql?

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/?-([^/]+)? product-details.php?pro_slug=$1&id=$2 [L,QSA]
RewriteRule ^([^/]+)/?-([^/]+)? blog-details.php?n_slug=$1&n_id=$2 [L,QSA]
this will working for only first defined page product-details.php. please help.
I am hitting on www.test.com/blog/Want-to-transfer-your-home-loan-to-another-bank, www.test.com/product/agriculture-land-near-by-agra First url should be served by product-details and 2nd one should be served by blog-details.php file.
Based on your shown samples, please try following htaccess Rule file.
Make sure to clear your browser cache before testing your URLs.
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(blog)/([\w-]+)/?$ product-details.php?pro_slug=$1&id=$2 [NC,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(product)/([\w-]+)/?$ blog-details.php?n_slug=$1&n_id=$2 [NC,L,QSA]

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>

Symfony2: simple rewrite rule in vhost to strip .html extention out

Since I migrated my project on Symfony2, I also avoided to use .html extensions previously used for my generated urls.
So, after looking at some examples, I'am trying to execute this in my /etc/apache2/sites-available/mysite:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.html$ $1 [NC,L]
#this is the standard rewrite rule to redirect every request to /web/app.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
I have tried many combinations but no one seems to work. Any Help? Thanks

htaccess is supposed to remove index.php from current URL, but instead redirects to root

I've read been reading StackOverflow posts for the last 30 minutes and none of them work. Maybe there is a server setup that is preventing this from working?
I just want to remove index.php from whatever URL is typed in. For example, www.mysite.com/blah/blah/index.php would become www.mysite.com/blah/blah/. www.mysite.com/index.php would become www.mysite.com/.
I've read at least 10 posts and tried each one, but it ALWAYS just redirects to the root. Here is the current code I'm using that looks like it should work:
Options +FollowSymLinks
Options +Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
Instead of just removing index.php from the URL, it redirects to the root of the site.
I think this is what you are looking for:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ $1/index.php [L,QSA]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
RewriteRule ^ /%1 [R=301,L]
</IfModule>

Wordpress .htaccess errors

Thanks in advance to all you .htaccess guru's out there. I'm having an issue that's been bothering me for some time. I have wordpress nested inside my own site folder structure. To the user, everything is cool. But when i go to www.domain.com/blog/wp-admin, my credentials will not log in. It just keeps looping me around to the same page. If I go to www.domain.com/blog/wp-login.php directly it works. I wonder if anyone knows why this is.
The blog is located at /fe/blog/.
The .htaccess in / is:
Options +FollowSymlinks -Indexes
RewriteEngine on
RewriteRule ^(files)/?(.*) /files/$2 [NC,L]
RewriteRule ^(.*) /fe/$1 [NC]
The .htaccess in /fe is:
Options +FollowSymlinks -Indexes
RewriteEngine on
And Finally the .htaccess in the /fe/blog/ is:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
Any help would be greatly appreciated!
Try this in your /.htaccess file:
RewriteEngine on
RewriteRule !^(files|fe)/ fe%{REQUEST_URI} [NC]
And this in your /fe/blog/.htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
i wonder if this line is not the culprit:
RewriteRule ^(files)/?(.*) /files/$2 [NC,L]
could you try:
RewriteRule ^files/?(.*) /files/$1 [NC,L]
If not, you might also add the flag [QSA] (Query String Append)
RewriteRule ^files/?(.*) /files/$1 [NC,L, QSA]