Trying to remove directory names from application URL - php

My badluck I'm a UI developer and given the task of URL rewriting please help me.
I've this URL with me /abc/def/ghi/somefile.php?id=1
I want it to just somefile?id=1
I do have this code in my .htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^/abc/def/ghi/(.*)$ /$1 [L,NC,R]
but after uploading the htaccess to server this is giving me 404 error after removing the /abc/def/ghi/ part.
Any help is greatly appreciated.

RewriteRule not receive first slash
RewriteRule ^abc/def/ghi/(.*)$ /$1 [L,NC,R]

Related

htaccess rewrite rule knowledge

I want to rewrite the url of mysite with help of htaccess. My website url which I need to rewrite is given below.
http://getallfreedownloads.com/category.php?slug=business_directory_listing
Result needed
http://getallfreedownloads.com/business_directory_listing or http://getallfreedownloads.com/business_directory_listing/
I have used the below code for rewrite rule in my htaccess file
RewriteEngine On
RewriteRule ^([^/]*)$ /category.php?slug=$1 [L]
Please guide me what I can do to make it work fine.
Note: After adding rewrite rule I have removed the " category.php?slug= " from the a Tag
I will be thank full to you all.
try this once.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^/category.php?slug(.*)$ /$1 [L,NC,R]

Remove folders from url using .htaccess issue

Hi So I am trying to remove includes/pagesfrom a url that looks like http://localhost:8888/london/includes/pages/soho-london-guide/ For local dev. I am using MAMP and I've enabled mod_rewrite too.
So far I've been trying to use different techniques and here is a list of what I've been using (trying to make it work :((( )
RewriteEngine ON
RewriteRule ^includes/pages/(.*)$ $1 [L,QSA]
Also
RewriteEngine on
RewriteBase /
RewriteRule ^/includes/pages/(.+)$ /$1 [L,QSA]
Very very new to .htaccess and regex syntax so any help would be appreciated.
Have this rule in your site root .htaccess:
RewriteEngine on
RewriteBase /
RewriteRule ^([\w-]+)/(?!includes/pages/)(.+)$ $1/includes/pages/$2 [L,NC]

URL rewrite problems

I am working on www.quippoauctions.com site here I am facing one problem. I have a
url: http://www.quippoauctions.com/index.php?do=auctiondetails&id=1134
i want to show this url as
http://www.quippoauctions.com/auctiondetails/1134/demo_auction_for_training_purpose.html
with the help of .htaccess file acn anyone help me on this
I have an htaccess file where I am writing
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^auctiondetails/(.*)/(.*).html$ ?do=auctiondetails&id=$1
try this
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/(.*)/demo_auction_for_training_purpose\.html$ /index.php?do=$1&id=$2
OR
RewriteRule ^auctiondetails/1134/demo_auction_for_training_purpose.html$ index.php?do=auctiondetails&id=1134 [L]

Hide extension as well as replace Question mark by slash in .htaccess

I have a problem i.e suppose the url is www.example.com/view.php?id=1 but I want the url is like that www.example.com/view/id/1 , seperately I get htaccess for hide extension or replace '?' by slash but both are not working please anybody help me .I want .htaccess working for both(extension hide and replace slash) and please make it general that is htaccess working for any page not any particular page.thanks in advance
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# external redirect from /view.php?id=1 to /view/id/1
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+([^.]+)\.php\?([^=]+)=([^\s&]+) [NC]
RewriteRule ^ /%1/%2/%3? [L,R=301]
# internal forward from /view/id/1 to /view.php?id=1
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /$1.php?$2=$3 [L,QSA]

SEO friendly url in PHP htaccess

I use Godaddy Apache server to build my own blog, and I did some search of SEO friendly url tutorials, and applied the following code in my web root .htaccess file to transfer links like http://www.bgmemo.com/blog.php?url=2012/08/23/4-steps-to-initialize-Apache-Derby-10-9-1-0-in-Netbeans-7-1-1.html to http://www.bgmemo.com/blog/2012/08/23/4-steps-to-initialize-Apache-Derby-10-9-1-0-in-Netbeans-7-1-1.html :
RewriteEngine on
RewriteRule ^([a-zA-Z0-9-/]+).html$ blog.php?url=$1
RewriteRule ^([a-zA-Z0-9-/]+).html/$ blog.php?url=$1
But it does not work. The htaccess is working and other code in it is applied. Who can tell me what is wrong? Thanks in advance.
Try this:
RewriteEngine on
RewriteBase /
RewriteRule ^blog/([a-zA-Z0-9\-/\.]+)/?$ blog.php?url=$1 [L]
This is the correctly way for donĀ“t have problems with your .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^blog/([a-zA-Z0-9\-/\.]+)/?$ blog.php?url=$1 [L]
</IfModule>

Categories