www.webdeveloper.com
Results 1 to 6 of 6

Thread: Rewrite URL in htaccess to hide certain characters

  1. #1
    Join Date
    Dec 2017
    Posts
    9

    Rewrite URL in htaccess to hide certain characters

    Hi guys
    I have a problem and also lack the understanding to put this rewrite rule in place.
    I only need to remove these characters from any URL on our website ?rid=

    from this:
    Code:
    https://rpmdigital.co.uk/coffee/?rid=A611F4
    to this:
    Code:
    https://rpmdigital.co.uk/coffee/A611F4
    The first section is created by wordpress https://rpmdigital.co.uk/coffee/
    and last part is created by an Xmpie system ?rid=A611F4
    the 6 digit number is dynamic and specific to making the webpage personalised to them.
    I have been told by Xmpie support that this can be done in the wordpress .hatches

    We use apache and Wordpress.
    The code I have in my .htaccess file on our apache server is this.

    PHP Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase 
    /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond 
    %{REQUEST_FILENAME} !-d
    RewriteRule 
    . /index.php [L]
    </
    IfModule
    is it possible to show me the process as i lack experience

    Really appreciate some help on this

    Kind Regards
    Matt

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    5,859
    URL Rewrite...

    You don't need to be looking for that sort of information, all you do is craft the ruleset to accept the URL in the format you want it to be like https://rpmdigital.co.uk/coffee/A611F4 and then behind the scenes, the URL rewrite rules link that to the data is found at like https://rpmdigital.co.uk/coffee/?rid=A611F4

    URL rewriting has nothing to do with taking it the other way around. Yes you will need a catch all filter but if someone has supplied the server with that URL then just serve it.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #3
    Join Date
    Dec 2017
    Posts
    9
    Thank you for your speedy reply Super Moderator.

    Unfortunatly that information is way over my head. My background is design, I have created fresh wordpress installs on cpanel servers many times but have never been required to delv to deeply into server configuration.

    Where would I start if i wanted to learn each process that I require to achieve this? is it one particular language, and where would I need to edit this code. Which file?

    Thank you for time either way

    Kind Regards
    Matt

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    5,859
    Basically you just write you URL as you want it to appear in a standard format as you have specified.

    URL Rewriting allows you to take apart that URL, apply it to an internally mapped deive, folde, file... and serve that page, data, folder contents as you dictate.

    so this https://domain.tld/coffee/A611F4 could with URL rewriting be pointed to https://domain.tld/index.php?cat=cof...oductId=A611F4

    However, if someone came to your server with the URL https://domain.tld/index.php?cat=cof...oductId=A611F4, just serve up the URL, no point in sending them around the houses when you could just as easily use that resource to just serve that URL.

    So a "Catch All" filter will "Catch All" URL's that fail the URL Rewrite rules, much better to control what is going on than end up with lots of 404 page errors.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  5. #5
    Join Date
    Dec 2017
    Posts
    9
    Thanks Super.
    I do not know how to maake catch all filters, or even where and what to add as code,
    Is there any tutorials on making basic URL rewrites ?

    Thanks for your time

    Matt

  6. #6
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    5,859
    You write the various rules that you need to redirect the incoming request.

    Any requests that do not match that rule are automatically passed to the next rule / condition pairing.

    Eventually all the rules you want to test for will run out and your final rule will redirect to any page you tell it to... "Catch all filtering"

    You can try looking at sites that help you generate URL Rewrite files, you will find them, its a case of searching for them. I tried free online URL rewriting tools and got 1.8 million results.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11102 seconds
  • Memory Usage 2,903KB
  • Queries Executed 16 (?)
More Information
Template Usage (34):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (6)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates