Web Design Forum: Htaccess URL re-write - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Htaccess URL re-write Rate Topic: -----

#1 User is online   brightonmike 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 2,996
  • Joined: 27-June 11
  • Reputation: 340
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 06 February 2012 - 10:18 AM

I'm trying to "prettify" a URL.

This is what I've added to my htaccess after Rewritenegine on:

RewriteRule ^request-sent-successfully$ wp-content/themes/kaexec/contactengine.php


What am I doing wrong? Still shows up as the ugly URL.
0

#2 User is online   Renaissance-Design 

  • Available for custom WordPress work
  • View blog
  • Group: Moderators
  • Posts: 3,595
  • Joined: 12-August 10
  • Reputation: 559
  • Gender:Male
  • Location:South Wales
  • Experience:Web Guru
  • Area of Expertise:Designer/Coder

Posted 06 February 2012 - 10:26 AM

I know this is really obvious, but it's Monday morning and it's exactly the sort of thing I'd do. Have you set your form action to the pretty URL?
0

#3 User is online   brightonmike 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 2,996
  • Joined: 27-June 11
  • Reputation: 340
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 06 February 2012 - 10:33 AM

I haven't...do I need to?
0

#4 User is online   Renaissance-Design 

  • Available for custom WordPress work
  • View blog
  • Group: Moderators
  • Posts: 3,595
  • Joined: 12-August 10
  • Reputation: 559
  • Gender:Male
  • Location:South Wales
  • Experience:Web Guru
  • Area of Expertise:Designer/Coder

Posted 06 February 2012 - 10:37 AM

Give it a whirl, yeah. Your rewrite is just saying to Apache "treat $prettyurl internally as if it were $uglyurl", anything that's shoved in the address bar by hrefs or form actions will stay as it is. So once you have a ruleset for all your pretty URLs, use them in your markup.
0

#5 User is online   brightonmike 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 2,996
  • Joined: 27-June 11
  • Reputation: 340
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 06 February 2012 - 10:42 AM

No such luck, I get a "Page not found"

action="<?php bloginfo('url'); ?>/request-sent-successfully"

This post has been edited by brightonmike: 06 February 2012 - 10:42 AM

0

#6 User is online   Renaissance-Design 

  • Available for custom WordPress work
  • View blog
  • Group: Moderators
  • Posts: 3,595
  • Joined: 12-August 10
  • Reputation: 559
  • Gender:Male
  • Location:South Wales
  • Experience:Web Guru
  • Area of Expertise:Designer/Coder

Posted 06 February 2012 - 10:54 AM

Aha. Works a bit differently in WordPress - .htaccess rewrites everything to index.php and WordPress does its own rewriting in PHP, because it uses the Front Controller pattern.

That'll be clashing with your WP rewrites, so get rid of it in .htaccess and use the WP Rewrite API instead.
0

#7 User is online   brightonmike 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 2,996
  • Joined: 27-June 11
  • Reputation: 340
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 06 February 2012 - 11:15 AM

This is my htaccess then:

add_rewrite_rule('^request-sent-successfully$', 'wp-content/themes/kaexec/contactengine.php', 'top');


Then make the POST url the pretty url?
0

#8 User is online   Renaissance-Design 

  • Available for custom WordPress work
  • View blog
  • Group: Moderators
  • Posts: 3,595
  • Joined: 12-August 10
  • Reputation: 559
  • Gender:Male
  • Location:South Wales
  • Experience:Web Guru
  • Area of Expertise:Designer/Coder

Posted 06 February 2012 - 11:27 AM

Is that bare in your functions.php or are you hooking it to something? Try something like this:

add_filter('rewrite_rules_array','MG_Rewrite');
add_filter('init','flushRules');  

function flushRules(){
    global $wp_rewrite;
    $wp_rewrite->flush_rules();
}

function MG_Rewrite($rules)
{
    $newrules = array();
    $newrules['^request-sent-successfully$'] = 'wp-content/themes/kaexec/contactengine.php';
    return $newrules + $rules;
}

0

#9 User is online   brightonmike 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 2,996
  • Joined: 27-June 11
  • Reputation: 340
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 06 February 2012 - 11:46 AM

I've added that in, am I POSTing to the new URL or the old?
0

#10 User is online   Renaissance-Design 

  • Available for custom WordPress work
  • View blog
  • Group: Moderators
  • Posts: 3,595
  • Joined: 12-August 10
  • Reputation: 559
  • Gender:Male
  • Location:South Wales
  • Experience:Web Guru
  • Area of Expertise:Designer/Coder

Posted 06 February 2012 - 12:01 PM

To the new.
0

#11 User is online   brightonmike 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 2,996
  • Joined: 27-June 11
  • Reputation: 340
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 06 February 2012 - 12:09 PM

No such luck, same problem as before, "Page cannot be found".

http://www.kaexec.com/request-sent-successfully

0

#12 User is online   Renaissance-Design 

  • Available for custom WordPress work
  • View blog
  • Group: Moderators
  • Posts: 3,595
  • Joined: 12-August 10
  • Reputation: 559
  • Gender:Male
  • Location:South Wales
  • Experience:Web Guru
  • Area of Expertise:Designer/Coder

Posted 06 February 2012 - 01:23 PM

Really? Damn. I hate troubleshooting WP rewrites. Is it generating WP's 404 or bypassing it and going straight for the server?

Also, what's the form for? Is there any reason it can't be embedded in a normal WP page and post to itself?
0

#13 User is online   brightonmike 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 2,996
  • Joined: 27-June 11
  • Reputation: 340
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 06 February 2012 - 03:56 PM

Hmm. This is a bit of a pain! I think for now I will leave it, and possibly just do a re-direct.
0

#14 User is online   Spitfire 

  • Mighty Pirate™
  • PipPipPipPip
  • Group: Members
  • Posts: 891
  • Joined: 05-February 11
  • Reputation: 189
  • Gender:Male
  • Location:Berkshire
  • Experience:Web Guru
  • Area of Expertise:Web Developer

Posted 06 February 2012 - 05:39 PM

RewriteRule ^wp-content/themes/kaexec/contactengine.php$ /request-sent-successfully/

0

#15 User is online   brightonmike 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 2,996
  • Joined: 27-June 11
  • Reputation: 340
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 07 February 2012 - 09:25 AM

Nope, still doesn't work. When I add that, the original URL 404s. I then tried changing the POST url to the new url and had the same result.
0

#16 User is offline   Wickham 

  • Web Guru
  • View gallery
  • Group: Moderators
  • Posts: 2,876
  • Joined: 11-June 09
  • Reputation: 257
  • Gender:Male
  • Location:Salisbury UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 07 February 2012 - 09:32 AM

Are you just testing locally while the .htaccess file is on the server? You need give the .htaccess file a chance to work.
0

#17 User is online   brightonmike 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 2,996
  • Joined: 27-June 11
  • Reputation: 340
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 07 February 2012 - 10:16 AM

Nope, this is live at the moment. I had to get the site up and running earlier than expected.

How long should it take?

Edit: Btw, when I did have it in, it didn't actually change the URL?

This post has been edited by brightonmike: 07 February 2012 - 10:19 AM

0

#18 User is online   brightonmike 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 2,996
  • Joined: 27-June 11
  • Reputation: 340
  • Gender:Male
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 07 February 2012 - 11:25 AM

Scrap this, altogether. I'm just gonna do a PHP redirect to a success page, works fine and no need to make a URL look pretty.
0

#19 User is offline   John Angel 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 20-February 12
  • Reputation: 0

Posted 20 February 2012 - 03:32 PM

What you could do is utilize the 404 handler. Set the 404 document to a PHP file, make this PHP file extract the URL on the address bar and redirect it to a particular page.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users