Jump to content

Search the Community

Showing results for tags 'mod_rewrite'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 22 results

  1. hello everyone. could you advise me on the structure of my code to check if it is correct: RewriteRule ^/user/([a-z]+)/cake/([a-z\ .*A-Zx0-9-_]+)$ /cakes.php?userid=$1&cakebaked=$2 what i am trying to do is to add a - instead of a whitespace which appears in the url as %20.
  2. Hello everybody, I am honestly quite a newb when it comes to mod_rewrite. We run a small social media page with different areas and I would like to change the URLs to something more clean and professional. User profiles look like this: http://www.sky-mp3.com/index.php?action=cm&siteid=59&wahl=artists&tat=details&keyid=477 siteid 59 is the artists list and the keyid at the end is the ID of the artist but should be like: http://www.sky-mp3.com/mischura or in worse case like: http://www.sky-mp3.com/user/mischura CMS pages look like this: http://www.sky-mp3.com/index.php?siteid=106 but should be like: http://www.sky-mp3.com/charts (page name instead of siteid) What I know so far: - I have to add something to the .htaccess file - I need to change something in the code (but I don`t know where) Im good he? What would be the first step on the path to clean URLs for me? I found alot of infos here and there but found nothing yet for this specific case. Kind regards from and thx in advance from Cologne
  3. Hi friends, I have to transform this url domain.com/main/folder1/folder2/folder3 to domain.com/get.php?var1=folder1&var2=folder2&var3=folder3 How can i do it with htaccess. Thank u
  4. About a year ago I wrote a mod_rewrite in at sites htaccess file. It was to call a page that queried the database based on a unite code that was assigned to a member. If the member was assigned a code that was FL1001, the URL www.marketingteammates.com/FL1001 would bring up a page that quaried that member and displayed their database content. In the users table of the site, it quaried the field webPageID and the information was called. It called a page webpage.php that quaried the info. The URL in the address bar still displayed www.marketingteammates.com/FL1001. Here are the lines of code in the htaccess file. RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([A-Za-z])([A-Za-z])([0-9]+)$ /webpage.php?webPageID=$1$2$3 [NC,L] I now have a second page completely different from the webpage.php. It is a page storeNumber.php and would query a field storeNumberID. This field could contain any kind of string such as Store#101, or mystore101, or #101 is my store. I tried using the same rewite rule just replaceing the webpage.php and variable with storeNumber.php and $storeNumberID. This doesn't work. It also leads me to wonder if there can even be two different pages in the mod_rewrite. How would it diferentiate one from the other. Thanks for any help in advance. Mike
  5. Hi, first I'm sorry if I posting this in wrong forum. So I've tried to make my url a little bit more 'user friendly' with .htaccess. For example this URL's http://localhost/index.php?currentpage=1 http://localhost/page.php?pn=1 http://localhost/gifs.php?id=1 http://localhost/pic.php?cat_id=1&id=5 My .htaccess content is: Options +FollowSymlinks RewriteEngine on RewriteRule ^currentpage/([^/]*)$ /index.php?currentpage=$1 [L] RewriteRule ^pn/([^/]*)$ /page.php?pn=$1 [L] RewriteRule ^id/([^/]*)$ /gifs.php?id=$1 [L] RewriteRule ^category-([^/]*)/([^/]*)$ /pic.php?cat_id=$1&id=$2 [L] ErrorDocument 404 http://localhost/404.php But it doesn't work...
  6. Hello, I have this rule in htaccess file that handles URL for item, Options All RewriteEngine On RewriteBase /www/ RewriteCond %{THE_REQUEST} \ /www/item\.php\?id=([0-9]+)&([^&\ ]+) RewriteRule ^ %1/%2? [L,R=301] RewriteRule ^([0-9]+)/(.*)$ item.php?id=$1&$2 [L,QSA,NE] in same htaccess I need to handle catlist also with this rule: RewriteCond %{THE_REQUEST} \ /www/category\.php\?id=([0-9]+)&([^&\ ]+) RewriteRule ^ %1/%2? [L,R=301] RewriteRule ^([0-9]+)/(.*)$ category.php?id=$1&$2 [L,QSA,NE] When I put them together only first one works Any solutions or ideas Thank You
  7. I'm new to mod_rewrite. I'm trying to rewrite my URLs, but it's not working. I have changed the URLs on my website to look like this: <a href="/id_number/hyphenated_article_title/">Anchor_text</a> E.g., <a href="/12/how-to-lose-weight-fast/">How to Lose Weight Fast</a> My .htaccess file looks like this: RewriteEngine on RewriteRule ^/([0-9]+)/[A-Za-z0-9-]+/?$ article.php?id=$1 [NC,L] The rewrite is working, but article.php is loading slowly and without CSS styling. Anyone know why?
  8. I'm trying to display products specific to a geographic location on the website. E.g. If a user selects city1 then my website url should change to city1.mysite.com. So the city1 part is dynamic on user selection. Please let me know how this is to be achieved and if this includes mod-rewrite or subdomains for each location. Thanks in advance.
  9. I want to know that mod_rewrite enable or not in my server You can see my php info file here http://www.grabkart.com/phpinfo.php
  10. i want to chage my website url http://www.oshopindia.com/productdetail.php?prodid=3649 to http://www.oshopindia.com/productdetail/3649 through mod_rewrite i hosted my website in subdirectory
  11. Hello Scenario I wish to hide the php extension and there is plenty of code on the net to handle this. I think this one would do the job and it work fine except for the instance below. Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / ## hide .php extension # To externally redirect /dir/foo.php to /dir/foo RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1 [R,L,NC] ## To internally redirect /dir/foo to /dir/foo.php RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^ %{REQUEST_URI}.php [L] The problem When I submit the form and re-load a page I use a named anchor to jump to the required point on the page. With the above code in place nothing happens at all , no form submission, no jumping to the correct page position... nothing except the page reloads. This is the form action example <form name="formName" method="post" action="<?=htmlentities($_SERVER['PHP_SELF'])?>#AnchorName" style="display: inline; margin: 0;"> I have very little knowledge in this area .... Any help is greatly appreciated.
  12. hey all, In honesty I have looked at tutorials for creating "pretty links" and I can honestly say I do not understand how to use it. I am using a navigation system that includes requested files using a URL like http://mysite.com?page=home. What I would like to do is make the links appear as http://mysite.com/page/home. How can I achieve this? I am not asking for the code to be written for me, just help in the right direction. Thanks
  13. Hi All Am trying to change the following url: http://mywebsite.com/gallery/cuisine/?nggpage=2linkid446 to read: http://mywebsite.com/gallery/cuisine/?nggpage=2?photoid=446 Have tried the following rules, but it does not want to change the url: RewriteCond %{REQUEST_URI} ^/gallery/cuisine/?nggpage=2linkid$1[a-z]+([0-9]+)$ RewriteRule ^(.*)$ /gallery/cuisine/\?nggpage=$2?photoid=%1 [R=301,NE,L] Regards, Charl
  14. Hi All Am trying to mod_rewrite a URL, but unfortunately without any luck. http://mywebsite.com/gallery/mycustom-gallery/linkid417 Should be changed to: http://mywebsite.com/gallery/mycustom-gallery/#417 Where '417' is a dynamic id of an image & mycustom-gallery will also change every-time. I've tried the following rules, but none seems to work... RewriteRule ^/gallery/$1/#([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/y/([0-9]+)$ /gallery/$1/linkid [L,R=301] RewriteRule mycustom-gallery/#.*$ /mycustom-gallery/linkid=417/$1 Regards, Charl
  15. I am not familiar with mod_rewrite at all, as I know I can change URL using htaccess bu can not figure how to do that so I appreciate if anybody can help me with expression that should be placed in htaccess. My current URL is I woul like to make it like this Thanks
  16. Thank you for reading. I am trying to rewrite all dynamic category links (/product_list.php?cat_id=xxx) to more "friendly" text links. The problem I'm running into is with subcategories: RewriteRule Complete-AC-Systems product_list.php?cat_id=2 works great, however when a sub category is present: RewriteRule Complete-AC-Systems__Packaged-Systems product_list.php?cat_id=7 the browser stops reading after Complete-AC-Systems and re-directs to product_list.php?cat_id=2 not cat_id=7 Most of our categories are 3 and 4 levels in, so this is a pervasive issue. Thanks for any help you can offer.
  17. my mod_rewrite is not affect to my link why? Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_URI} news/ RewriteCond %{REQUEST_URI} tips/ RewriteCond %{REQUEST_URI} views/ RewriteRule news/ menu.php?ph_sc_menu_id=1 [L] RewriteRule tips/ menu.php?ph_sc_menu_id=2 [L] RewriteRule views/ menu.php?ph_sc_menu_id=3 [L] if i key on my url box it working but when i click my navigation menu it still display menu.php?ph_sc_menu_id=3
  18. So I have the below code doing two things. The first part removing .php extension from urls and the second part redirecting from a clean url to the original. Its the second part of this that is not working and I dont know why and am hoping and praying someone here can help with this. I have tried many different tutorials with different approaches and still no luck. Below is the most basic of the attempts I have tried and from what I can tell it SHOULD work, but alas... Anyway its trying to get the clean url example.com/post/2 to redirect to example.com/post.php?id=2 Please help! RewriteEngine On #remove .php extension RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1\.php [L] #redirect RewriteRule ^/post/([0-9]+)$ /post.php?id=$1
  19. So, my host's mod_rewrite seems to be messed up or something is wrong with their software. I'm not really sure and the host refuses to fix it or give me my money back so I'm stuck with it. Anyway, so I'm saying, mod_rewrite doesn't work. How would I mod the script so that it does not need to depend on mod_rewrite? A general answer will probably do fine. Do I just go through every single page and the ones that have a link, I link it to the .php page and not the mod_rewrite one? Sorry, I'm a little confused.
  20. I have successfully created my mod_rewrite rule to change all dynamic URLs on the top level of the site, but now i need to create a rule for a second level, and i think later down the line i might need a second, second level of rewrites. At the moment i have this RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.+)$ index.php?subj=$1 And this helps to change /index.php?subj=home to /home as it does for all other pages such as /contact /about /events and so on. But now I have created sub pages under events and therefore need to change /events.php?event=event-name to events/event-name. But when i add another rule it messes up the whole site. What i tried to do is this RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.+)$ index.php?subj=$1 RewriteRule ^events/(.+)$ event.php?event=$1 I've even tried it with [L] flags after the Rewrite rules, but nothing seems to work, I would really appreciate it if someone can show me the best way to do this as nothing seems to work. Many thanks in advance
  21. I have an application that runs several sites on base configs, but allows those sites to change their imagery. As it stands right now, the image paths and .htaccess is as so: RewriteCond %{REQUEST_FILENAME} !-f RewriteRule img/.+/(.*) img/$1 [L] www/ \ js/ \ img/ \\ site1/ \\ site2/ 1.png 2.png... <img src="img/{$Site->id()}/1.png" /> The .htaccess rule basically permits me to path all images to a user's account id, and when not found it serves from the base img directory. Nothing too special. I'd rather not have to deal with write permissions, so I've made an external repository that i'll save the images into. Basic structure is /repository/site/<site id>/<img>|<pdf>|<etc>. The code is versioned through github, so I don't think symlinks would work. To combat this, here is my weak attempt: # when the URI matches img/<id>/<img>, serve from repo path RewriteCond %{REQUEST_URI} img/.+/(.*) RewriteRule img/(.+)/(.*)$ /repository/sites/$1/$2 [L] # if that doesn't exist, server from web path RewriteCond /repository/sites/8/%{REQUEST_FILENAME} !-f RewriteRule img/.+/(.*) img/$1 [L] Produces logs like so: x.x.x.x- - [30/Oct/2012:14:59:28 --0400] [xx][rid#9cfe1d8/subreq] (1) [perdir /home/a/b/c/www/] internal redirect with /index.php/repository/sites/8/img/interface_splash.png [iNTERNAL REDIRECT] x.x.78.1 - - [30/Oct/2012:14:59:28 --0400] [xx][rid#9d3a7c8/initial] (1) [perdir /home/a/b/c/www/] internal redirect with /index.php/ [iNTERNAL REDIRECT] x.x.78.1 - - [30/Oct/2012:14:59:28 --0400] [xx][rid#9d8bdb8/initial/redir#1] (1) [perdir /home/a/b/c/www/] pass through /home/a/b/c/www/index.php x.x.78.1 - - [30/Oct/2012:14:59:28 --0400] [xx][rid#9d42a58/subreq] (1) [perdir /home/a/b/c/www/] internal redirect with /index.php/ [iNTERNAL REDIRECT] Any idea how I can dynamically server assets from outside the webroot?
  22. I'm fairly new to developing sites with dynamically generated pages and have just built my first CMS. Currently all pages come off the index and are pulled from its ID number and their URLs are like this mydomain.com/directory/index.php?subj=1 Its still in production so i only have three pages; Home, Events and Contact. Each one is represented by ID 1, 2 and 3. I have managed to create an .htaccess file and have successfully changed the URL to mydomain.com/directory/1/ (although i think im going to remove that trailing slash). But what i really want to do is pull the page title (except for home which should come off the root) but i just cant seem to get my head around it. If anyone could point me in the right direction I would be very grateful. Basically I need the URL to look something like this mydomain.com/directory/contact At the moment my .htsccess file looks like this RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^([a-zA-Z0-9]+)/$ index.php?subj=$1 Cheers
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.