Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,803 members, 7,956,057 topics. Date: Sunday, 22 September 2024 at 10:50 PM |
Nairaland Forum / Science/Technology / Webmasters / htaccess (942 Views)
Wordpress Permalink,.htaccess Problem +directory Problem Help Please / How To Find .htaccess File / Please Who Knows How To Set A 'no Follow' Tag Through Htaccess? (2) (3) (4)
htaccess by afridigit(m): 6:01pm On Nov 16, 2013 |
Hi Nairalanders, I am trying to rewrite these link using Apache mod_rewrite on WAMP <a href="page.php?n=Ecommerce software&src=7" title="Premium Ecommerce Solution">Ecommerce Software</a> I have enable mod_rewritr on the server and have change allowOveride None to allowOveride All Here is my .htaccess file. I save it as .htaccess on the directory that has the file with the link. RewriteEngine On RewriteRule ^page/.*/([0-9]+)$ /page.php?n=$1&src=$2 [NC,L] Or RewriteEngine On RewriteRule ^page/([a-zA-Z0-9_-]+)/([0-9]+)/$ page.php?n=$1&src=$2 [NC,L] But it not working. Please help me to get it right? Thanks. |
Re: htaccess by spikesC(m): 7:17pm On Nov 16, 2013 |
From the first rule:
It should be RewriteRule ^page/(.*)/([0-9]+)$ /page.php?n=$1&src=$2 [NC,L ,QSA ] //I added QSA so that you can also pass GET variables From the second rule:
It should be RewriteRule ^page/([a-zA-Z0-9\_\-]+)/([0-9]+)/$ page.php?n=$1&src=$2 [NC,L] //I escaped it in case it is a special character |
Re: htaccess by spikesC(m): 7:20pm On Nov 16, 2013 |
Btw, i would suggest, whiles generating the urls, you replace also spaces with +, remove non alphanumeric characters and tag the src id with a hyphen. Using a slash seems like it's a folder like structure. Example: instead of page/economy/1 you do page/economy-1 you then use slashes to designate pages(i.e page 1, page 2 etc.) Your choice though |
Re: htaccess by afridigit(m): 11:21pm On Nov 16, 2013 |
Thank you Spikes C. I copied your rule, save it and upload it. test it online and locally. But it did not work. Can PHP function affect it? |
Re: htaccess by spikesC(m): 11:27pm On Nov 16, 2013 |
Hope your .htaccess looks like this
Remove all codes in it and test with just the one above. Then keep adding the others line by line (if you have any) till you jam the supposed error 500 |
Re: htaccess by spikesC(m): 11:33pm On Nov 16, 2013 |
Seems you already did. What's the error if i may ask? And i hope you restarted WAMP when you enabled mod_rewrite |
Re: htaccess by afridigit(m): 5:03pm On Nov 17, 2013 |
Thanks once more. Actually there is no error message. But it did not rewrite the links even when i copied code below in your post. I restarted the Apache service.
|
Re: htaccess by spikesC(m): 7:30pm On Nov 17, 2013 |
ewoooo It doesn't redirect the links, it rewrites it internally When you visit /page/economics/7 You'll see it working. That's the koko of the rule. Therefore it was working |
Re: htaccess by olyivy(f): 7:44pm On Nov 17, 2013 |
afridigit: Thanks once more.hope u werent expecting apache to change the ugly url to the pretty one for u with just the .htaccess code up there? You have to test with ur rewrited url and see if the page is served. Again, did u confirm that ur .htaccess works cos last time i enabled it on wamp, after changing all the things u already changed in th httpdconf, i needed to also uncomment header modules and something else on that conf file before it started working. The question then is: are you getting the 500 internal server error? |
Re: htaccess by olyivy(f): 7:51pm On Nov 17, 2013 |
---- |
Re: htaccess by afridigit(m): 8:05am On Nov 19, 2013 |
olyivy: hope u werent expecting apache to change the ugly url to the pretty one for u with just the .htaccess code up there? Yes. .htaccess is working. because when i alter the code i will have 500 internal error. But right now i am not geting the 500 internal error. |
Re: htaccess by afridigit(m): 8:21am On Nov 19, 2013 |
I am new to Apache or have very little knowledge about it. But my focus is to change a url that look like www.mydomain.com/page.php?n=eccommerce-software&src=7 to somthing like www.mydomain.com/page/eccommerce-software/7 and just like the one we have on nairaland. Any way you can mentor me to achieve it, please do even if it involve paying for the training. Thanks. |
Re: htaccess by spikesC(m): 8:39am On Nov 19, 2013 |
You have already done the job. After including that right code into your .htaccess Visit the beutiful url, if it works, then your code works. Simple |
Re: htaccess by afridigit(m): 12:58pm On Nov 19, 2013 |
Thank you guys very much. Finally i got what you mean. You guys are really gurus. I will still come back when i get choked. Great to have you. |
(1) (Reply)
Help: How To Create A "Read More" Drop Meun / Tutorial - How To Get An Approved Adsense Account For Your Website / Domain Names Are Like Dynosours..
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 20 |